📄 app10_1.java
字号:
// app10_1, 抽象类的实例
abstract class CShape //定义抽象类CShape
{
protected String color;
public void setColor(String str){
color=str;
}
abstract void show(); // 只声明show(),但没有定义处理方法
}
class CRectangle extends CShape // 定义子类CRectangle
{
int width,height;
public CRectangle(int w,int h){
width=w;
height=h;
}
public void show(){ // 明确定义继承自抽象类的Show() method
System.out.print("color="+color+", ");
System.out.println("area="+width*height);
}
}
class CCircle extends CShape // 定义子类CCircle
{
double radius;
public CCircle(double r){
radius=r;
}
public void show(){ //
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -