?? demo.java
字號:
// 5-22 如何運用抽象類。package Demo;abstract class Shape{ int position_x,position_y; // 坐標 變量 void MoveTo(int new_pos_x,int new_pos_y){ position_x=new_pos_x; position_y=new_pos_y; } abstract void draw(); // 抽象方法}class Square extends Shape{ int length; void draw(){ System.out.println("this is a square."); }}class Circle extends Shape{ int radius; void draw(){ System.out.println("this is a circle."); }}class Trigon extends Shape{ int bottom; int highness; void draw(){ System.out.println("this is a trigon."); }}class ShapeManager{ void manager(Shape obj){ obj.draw(); }}public class Demo { public static void main(String args[]){ ShapeManager shape_man=new ShapeManager(); Square sq=new Square(); Circle ci=new Circle(); Trigon tr=new Trigon(); shape_man.manager(sq); shape_man.manager(ci); shape_man.manager(tr); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -