?? useshapes.java
字號:
/*
* Created on 2005-10-9
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package polymorphism;
/**
* From 'Thinking in Java, 2nd ed.' by Bruce Eckel
*/
public class UseShapes {
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();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -