java题,求大神解答
class Auto {public int 轮胎数量;public String 汽车颜色;public double 车身重量;public double 速度;Auto() {// 无参构造}Auto(int 轮胎数量, String 汽车颜色, double 车身重量, double 速度) {// 有参构造this.轮胎数量 = 轮胎数量;this.汽车颜色 = 汽车颜色;this.车身重量 = 车身重量;this.速度 = 速度;}
Auto 类:
public class Auto {
private int num;//轮胎个数
private String coler; //颜色
private double weight; //重量
private double move; //速度
public Auto(){}
public Auto(int num){
this.num = num;
}
public Auto(double weight){
this.weight = weight;
}
public Auto(String coler){
this.coler = coler;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public String getColer() {
return coler;
}
public void setColer(String coler) {
this.coler = coler;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
public double getMove() {
return move;
}
public void setMove(double move) {
this.move = move;
}
}
实例化类:
public class Test {
Auto a = new Auto();
Auto a1 = new Auto(1);
Auto a2 = new Auto("red");
Auto a3 = new Auto(3.0);
}
下一篇:景区标识系统分几类?
上一篇:23D4转十六进制转二进制