⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demo.java~5~

📁 提供了常用的JAVA技术的示例
💻 JAVA~5~
字号:
// 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 show(){        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 + -