黑马程序员技术交流社区
标题:
标准Javabean实现
[打印本页]
作者:
MichaelLian
时间:
2016-4-15 21:46
标题:
标准Javabean实现
class Test_Rectangle02 {
public static void main(String[] args) {
Rectangle02 rec1=new Rectangle02();
rec1.setHigh(3);
rec1.setWidth(4);
System.out.print("Circle is "+rec1.getCircle()+" "+"Area is "+rec1.getArea());
System.out.println();
Rectangle02 rec2=new Rectangle02(5,6);
rec2.show();
}
}
class Rectangle02{
private int high;
private int width;
public Rectangle02(){}
public Rectangle02(int high,int width){
this.high=high;
this.width=width;
}
public void setHigh(int high){
this.high=high;
}
public void setWidth(int width){
this.width=width;
}
public int getCircle(){
return 2*(high+width);
}
public int getArea(){
return high*width;
}
public void show(){
System.out.print("High is "+high+" "+"width is "+width);
}
}
复制代码
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2