private double length;
private double width;
//構造函數
Retangle(double length,double width){
this.length = length;
this.width = width;
}
//方法
public double getArea(){
return length*width;
}
public double getGirth(){
return 2*(length+width);
}
public static void main(String[] args){
Rectangle rec = new Rectangle(3,4);
System.out.println("面積為:"+rec.getArea());
System.out.println("周長為:"+rec.getArea());
}
}