class Squre extends shapeDome{
private int chang;
private int kuan;
public int getChang() {
return chang;
}
public void setChang(int chang) {
this.chang = chang;
}
public int getKuan() {
return kuan;
}
public void setKuan(int kuan) {
this.kuan = kuan;
}
public void girth() {
setChang(10);
setKuan(5);
int girth =2*(getChang()+getKuan());
System.out.println("周长为"+girth);
}
public void area() {
setChang(10);
setKuan(5);
int area=getChang()*getKuan();
System.out.println("面积为"+area);
}
}
class Circle extends shapeDome{
private int banjing;
public int getBanjing() {
return banjing;
}
public void setBanjing(int banjing) {
this.banjing = banjing;
}
public void girth() {
setBanjing(5);
double girth=3.14*getBanjing();
System.out.println("周长为"+girth);
}
public void area() {
setBanjing(5);
double area=3.14*getBanjing()*getBanjing();
System.out.println("面积为"+area);
}
}
public abstract class shapeDome {
public abstract void girth();
public abstract void area();
}
public class Initalshap {
public static void main(String[] args) {
Squre s=new Squre();
s.getChang();
s.getKuan();
s.girth();
s.area();
Circle c=new Circle();
c.getBanjing();
c.girth();
c.area();
}
}
一曝十寒
相关分类