标签:getwidth tle inf img getheight 修改 技术 test return
package two;
class Rectangle{
private double width;
private double height;
private String color;
public Rectangle(double width,double height,String color) {
this.setWidth(width);
this.setHeight(height);
this.setColor(color);
}
public double getWidth() {
return width;
}
public void setWidth(double x) {
width = x;
}
public double getHeight() {
return height;
}
public void setHeight(double y) {
height = y;
}
public String getColor() {
return color;
}
public void setColor(String z) {
color = z;
}
public void getArea() {
System.out.println("面积:"+getHeight()*getWidth());
}
public void getLength() {
System.out.println("周长:"+(getHeight()+getWidth())*2);
}
public void getTest() {
System.out.println("颜色:"+getColor());
}
}
public class w1 {
public static void main(String[] args) {
Rectangle per=new Rectangle(5.0,5.0,"red");
per.getArea();
per.getLength();
per.getTest();
}
}
标签:getwidth tle inf img getheight 修改 技术 test return
原文地址:https://www.cnblogs.com/wuguijunniubi/p/11557888.html