为甚么结果输出的载客量与载货量为0
package HomeWork;
import java.io.InputStream;
import java.util.Scanner;
//是否借车》可借车辆展示》选择想借几款类型》选择租借车辆款式》打印账单
public class Rentsys {
public void showcars() {
Car[] cars = new Car[3];
cars[0] =new SUV(1,"SUV轿车",300,6);
cars[1]=new GoodCar(2,"大货车",300,8);
cars[2]=new Pickup(3,"皮卡",200,6,4.0);
System.out.println("有以下可租车辆:");
for (int i = 0; i < cars.length; i++) {
if (i==0) {
System.out.println("车辆编号:"+(i+1)+"车型:"+cars[i].getBrand()+"费用(元/天):"+cars[i].getFee()+"载客量:"+
cars[i].getPersoncapacity());
} else if (i==1) {
System.out.println("车辆编号:"+(i+1)+"车型:"+cars[i].getBrand()+"费用(元/天):"+cars[i].getFee()+"载客量:"+
cars[i].getThingcapacity());
} else {
System.out.println("车辆编号:"+(i+1)+"车型:"+cars[i].getBrand()+"费用(元/天):"+cars[i].getFee()+"载客量:"+
cars[i].getPersoncapacity()+"载货量:"+cars[i].getThingcapacity());
}
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("欢迎使用达达,请问是否租车?");
System.out.println("1.是 2.否");
Scanner sc = new Scanner(System.in);
int in = sc.nextInt();
if (in==1) {
Rentsys rent = new Rentsys();
rent.showcars();
} else {
System.out.println("欢迎下次光临!");
}
}
}
欢迎使用达达,请问是否租车?
1.是 2.否
1
有以下可租车辆:
车辆编号:1车型:SUV轿车费用(元/天):300载客量:0
车辆编号:2车型:大货车费用(元/天):300载客量:0.0
车辆编号:3车型:皮卡费用(元/天):200载客量:0载货量:0.0