package car;
public abstract class car {
protected int price;
protected string name;
protected int getprice() {
return price;
}
protected string getname() {
return name;
}
public int getpersonnum() {
// todo auto-generated method stub
return 0;
}
public int getgoodsnum() {
// todo auto-generated method stub
return 0;
}
}
mannedcar.java:
package car;
public class mannedcar extends car {
private int personnum;
public mannedcar() {
this.personnum = 0;
this.price = 0;
this.name = "";
}
public mannedcar(int personnum, int price, string name) {
this.personnum = personnum;
this.price = price;
this.name = name;
}
@override
public int getpersonnum() {
return personnum;
}
}
truck.java:
package car;
public class truck extends car{
private int goodsnum;
public truck() {
this.price = 0;
this.goodsnum = 0;
this.name = "";
}
public truck(int price, int goodsnum, string name) {
this.price = price;
this.goodsnum = goodsnum;
this.name = name;
}
@override
public int getgoodsnum() {
return goodsnum;
}
}
bothcarry.java:
package car;
public class bothcarry extends car {
private int personnum;
private int goodsnum;
public bothcarry() {
this.personnum = 0;
this.goodsnum = 0;
this.name = "";
this.price = 0;
}
public bothcarry(int price, int personnum,
int goodsnum, string name) {
this.personnum = personnum;
this.goodsnum = goodsnum;
this.price = price;
this.name = name;
}
public int getpersonnum() {
return personnum;
}
public int getgoodsnum() {
return goodsnum;
}
}