用JAVA编写代码?急求···
来源:百度知道 编辑:UC知道 时间:2024/09/20 03:04:05
汽车具有长,宽,高和颜色等属性,定义一个表示汽车的类Car ,定义构造函数对汽车的属性进行初始化,并定义一个方法ShowCar()用于实现汽车的属性。
//有了eclipse这个不怕..
public class Car {
private float length;
private float width;
private float height;
private String color;
public Car() {
}
public Car(String color, float height, float length, float width) {
super();
this.color = color;
this.height = height;
this.length = length;
this.width = width;
}
public float getLength() {
return length;
}
public void setLength(float length) {
this.length = length;
}
public float getWidth() {
return width;
}
public void setWidth(float width) {
this.width = width;
}
public float getHeight() {
return height;
}
public void setHeight(float height) {
this.height = height;
}
public String getColor() {
return color;
}
public void setColor(String color