计算长方形的周长和面积
class Rectangle{
private int width;
private int height;
public Rectangle(int width,int height) {
this.setWidth(width);
this.setHeight(height);
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
if (width<=0) {
System.out.println("输入有误");
return;
}else{
this.width = width;
}
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
if (height<=0) {
System.out.println("输入有误");
return;
}
else{
this.height = height;
}
}
int getZhouchang(){
return (this.getWidth()+this.getHeight())*2;
}
int getArea(){
return this.getHeight() * this.getWidth();
}
}
public class Test1 {
public static void main(String[] args) {
Rectangle R=new Rectangle(1, 10);
System.out.println(());
System.out.println(());
}
}