使用继承思想实现汽车类,以及公交车和卡车类,要求用到this,super关键字
public class Car {
private String name ;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Car(){}
}
class Bus extends Car{
private int tickt;
public int getTickt() {
return tickt;
}
public void setTickt(int tickt) {
this.tickt = tickt;
}
public Bus(){
super();
}
}
class Lorry extends Car{
private double weight;
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
public Lorry(){
super();
}
}