public class obl {
private double d;
private double h;
private square s=new square();
public double getArea(){
return d*h;
}
public void setD(double d){
this.d=d;
}
public void setH(double h){
this.h=h;
}
public static void main(String[] args) {
new obl().s.x=10;
}
class square{
private double x;
public double getArea(){
return x*x;
}
public void setX(double x){
this.x=x;
}
}
}
class circle{
private double r;
public double getArea(){
return 3.14*r*r;
}
public void setR(double r)
{
this.r=r;
}
}
class trigon{
private double d;
private double h;
public double getArea(){
return 0.5*d*h;
}
public void setD(double d){
this.d=d;
}
public void setH(double h){
this.h=h;
}
}
public class test {
public static void main(String[] args) {
circle c=new circle()
c.setR(4.0)
System.out.println("圆形的面积:"+c.getArea())
obl o=new obl()
o.setD(2.0)
o.setH(3.0)
System.out.println("长方形的面积:"+o.getArea())
trigon t=new trigon()
t.setH(3.0)
t.setD(4.0)
System.out.println("三角形的面积是:"+t.getArea())
// square s=new square()
// s.setX(5.0)
// System.out.println("正方形的面积是:"+s.getArea())
//obl.square s=new obl.square()
}
}