这是我自己写的作业,代码比较简单,希望大家看到可以看下并指出可以精简的部分https://www.imooc.com/article/44300
public class Initail {
public static void main(String[] args){
Shape shape = new Circle();
shape.mj();
shape.zc();
Shape shape1 = new Rectangle();
shape1.mj();
shape1.zc();
}
}
public static void main(String[] args){
Shape shape = new Circle();
shape.mj();
shape.zc();
Shape shape1 = new Rectangle();
shape1.mj();
shape1.zc();
}
}
2018-07-02
public abstract class Shape {
public abstract void mj();
public abstract void zc();
}
public abstract void mj();
public abstract void zc();
}
2018-07-02
public class Rectangle extends Shape {
int r = 5;
@Override
public void mj() {
System.out.println(" 圆的面积:"+(Math.PI*r*r));
}
@Override
public void zc() {
System.out.println(" 圆的周长:"+(Math.PI*2*r));
}
}
int r = 5;
@Override
public void mj() {
System.out.println(" 圆的面积:"+(Math.PI*r*r));
}
@Override
public void zc() {
System.out.println(" 圆的周长:"+(Math.PI*2*r));
}
}
2018-07-02