當前位置:編程學習大全網 - 站長素材 - 求用Java編壹個小程序

求用Java編壹個小程序

class Retangle{

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());

}

}

  • 上一篇:作文素材高考版怎麽樣?有家長給孩子買過嗎?
  • 下一篇:遊戲原畫的制作過程和軟件
  • copyright 2024編程學習大全網