1.
package test;
public class Rectangle {
private double width,height;
private String color;
public Rectangle(String color,double width,double height) {
this.setWidth(width);
this.setHeight(height);
this.setColor(color);
}
public double getHeight() {
return height;
}
public void getLength() {
System.out.println("周长为"+(getWidth()+getHeight())*2);
}
public void getArea() {
System.out.println("面积为"+getWidth()*getHeight());
}
public void getColor2() {
System.out.println("颜色为"+getColor());
}
public double getWidth() {
return width;
}
public void setWidth(double i) {
width=i;
}
public void setHeight(double n) {
height=n;
}
public String getColor() {
return color;
}
public void setColor(String s) {
color=s;
}
public static void main(String [] args) {
Rectangle per=new Rectangle("红色",15.00,3.00);
per.getLength();
per.getArea();
per.getColor2();
}
}
2.想了很久不会写
课程总结:上课时候没那么认真 导致这次作业写不好 下次上课要更加认真 不被课程甩下去了