1个回答
展开全部
public class Rectangle {
// 矩形的长和宽
private double width;
private double height;
// 构造方法可以多个,只要参数不一样就可以
// 默认构造方法
public Rectangle() {
}
public Rectangle(double width, double height) {
this.height = height;
this.width = width;
}
public double getResult() {
return 2 * (this.height + this.width);
}
public double getWidth() {
return width;
}
public void setWidth(double width) {
this.width = width;
}
public double getHeight() {
return height;
}
public void setHeight(double height) {
this.height = height;
}
}
// 矩形的长和宽
private double width;
private double height;
// 构造方法可以多个,只要参数不一样就可以
// 默认构造方法
public Rectangle() {
}
public Rectangle(double width, double height) {
this.height = height;
this.width = width;
}
public double getResult() {
return 2 * (this.height + this.width);
}
public double getWidth() {
return width;
}
public void setWidth(double width) {
this.width = width;
}
public double getHeight() {
return height;
}
public void setHeight(double height) {
this.height = height;
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询