简单的java小程序! java我不懂,同学的作业,没办法 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不过给你个参考://: c07:Shapes.java// From 'Thinking in Java, 2nd ed.' by Bruce Eckel// www.BruceEckel.com. See copyright notice in CopyRight.txt.// Polymorphism in Java.class Shape { void draw() {} void erase() {} }class Circle extends Shape { void draw() { System.out.println("Circle.draw()"); } void erase() { System.out.println("Circle.erase()"); }}class Square extends Shape { void draw() { System.out.println("Square.draw()"); } void erase() { System.out.println("Square.erase()"); }}class Triangle extends Shape { void draw() { System.out.println("Triangle.draw()"); } void erase() { System.out.println("Triangle.erase()"); }}public class Shapes { public static Shape randShape() { switch((int)(Math.random() * 3)) { default: case 0: return new Circle(); case 1: return new Square(); case 2: return new Triangle(); } } public static void main(String[] args) { Shape[] s = new Shape[9]; // Fill up the array with shapes: for(int i = 0; i < s.length; i++) s[i] = randShape(); // Make polymorphic method calls: for(int i = 0; i < s.length; i++) s[i].draw(); }} ///:~ 给你个建议随便找一本java书去抄一下不过说实在的您这问题确实简单了点但是要是一行一行的编有点郁闷 java中的光标问题 求750*500左右的gif动态背景图片 我想做一个象EXCEL那样的窗口框架,外面是菜单栏,工具栏,然后每打开一个表就显示在下面的区域里应该怎样做?可以给个例子吗?谢谢!, java如何实现多态 用程序访问某个网页,得到“访问原网页失败!” swing编程 如何在Frame里加入日期和时间。格式显示出来 可以编辑时间,和日期 java里面有没有这样一个方法阿??? 高分求内部类的问题 问一个关于irc聊天室技术的问题 一个关于引用及类与类关系的问题请教! 一些很基础的问题,请大家帮我解答,共同提高,谢谢!!````
//: c07:Shapes.java
// From 'Thinking in Java, 2nd ed.' by Bruce Eckel
// www.BruceEckel.com. See copyright notice in CopyRight.txt.
// Polymorphism in Java.class Shape {
void draw() {}
void erase() {}
}class Circle extends Shape {
void draw() {
System.out.println("Circle.draw()");
}
void erase() {
System.out.println("Circle.erase()");
}
}class Square extends Shape {
void draw() {
System.out.println("Square.draw()");
}
void erase() {
System.out.println("Square.erase()");
}
}class Triangle extends Shape {
void draw() {
System.out.println("Triangle.draw()");
}
void erase() {
System.out.println("Triangle.erase()");
}
}public class Shapes {
public static Shape randShape() {
switch((int)(Math.random() * 3)) {
default:
case 0: return new Circle();
case 1: return new Square();
case 2: return new Triangle();
}
}
public static void main(String[] args) {
Shape[] s = new Shape[9];
// Fill up the array with shapes:
for(int i = 0; i < s.length; i++)
s[i] = randShape();
// Make polymorphic method calls:
for(int i = 0; i < s.length; i++)
s[i].draw();
}
} ///:~
随便找一本java书去抄一下
不过说实在的
您这问题确实简单了点
但是要是一行一行的编
有点郁闷