package xxx;
public abstract class Shape {
public abstract void square();
public abstract void zhouchang();
}
package xxx;
public class Rectangle extends Shape {
int chang=8;
int kuan=6;
int square=chang*kuan;
int zhouchang=(chang+kuan)*2;
@Override
public void square() {
// TODO Auto-generated method stub
}
@Override
public void zhouchang() {
// TODO Auto-generated method stub
}
public void cal(){
System.out.println("矩形的面积为:"+square+" "+"周长为"+zhouchang);
}
}
package xxx;
public class Circle extends Shape {
double r=6.00;
double square=3.14*r*r;
double zhouchang=0.50*3.14*r;
@Override
public void square() {
// TODO Auto-generated method stub
}
@Override
public void zhouchang() {
// TODO Auto-generated method stub
}
public void cal(){
System.out.println("圆形的面积为:"+square+" "+"周长为"+zhouchang);
}
}
package xxx;
public class initail {
public static void main(String[] args) {
Shape obj1=new Circle();
Shape obj2=new Rectangle();
obj1.square();
obj1.zhouchang();
obj2.square();
obj2.zhouchang();
}
}