Java语言程序设计(基础篇)第十版

来源:互联网 发布:mac os系统简介 编辑:程序博客网 时间:2024/05/18 13:48

package adsads;

public class adfsa
{ public static void main(String[] args)
{
Rectangle rectangle1=new Rectangle(4,40);
Rectangle rectangle2=new Rectangle(3.5,35.9);
System.out.println("The rectang1's width is"+rectangle1.width+"and height"+rectangle1.height+"and area is"+rectangle1.getArea()+"and zhouchang is"+rectangle1.getPerimeter());
System.out.println("The rectang2's width is"+rectangle2.width+"and height"+rectangle2.height+"and area is"+rectangle2.getArea()+"and zhouchang is"+rectangle2.getPerimeter());
}
}
class Rectangle
{
double width=1;
double height=1;
Rectangle(){

}
Rectangle(double width1,double height1)
{
width=width1;
height=height1;
}
double getArea(){
return width*height;
}
double getPerimeter(){
return 2*(width+height);
}
}

阅读全文
0 0