答答租车系统 求大神帮忙修正,一直搞不好

289 查看

package dadaxitong;

public class Allcar {
private String name;
private int price;
private int burden;
private int busload;
}

package dadaxitong;

public class Goodscar extends Allcar {
private String name;
private int price;
private int burden;
public Goodscar(String name,int price,int burden){
this.name=name;
this.price=price;
this.burden=burden;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public int getBurden() {
return burden;
}
public void setBurden(int burden) {
this.burden = burden;
}

}

package dadaxitong;

public class Passenger extends Allcar {
private String name;
private int price;
private int busload;
public Passenger(String name,int price,int busload){
this.name = name;
this.price = price;
this.busload = busload;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public int getBusload() {
return busload;
}
public void setBusload(int busload) {
this.busload = busload;
}
}

package dadaxitong;

public class Doubleusecar extends Allcar {
private String name;
private int price;
private int busload;//载客量
private int burden;//载货量
public Doubleusecar(String name,int price,int busload,int burden){
this.name = name;
this.price = price;
this.busload = busload;
this.burden = burden;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public int getBusload() {
return busload;
}
public void setBusload(int busload) {
this.busload = busload;
}
public int getBurden() {
return burden;
}
public void setBurden(int burden) {
this.burden = burden;
}

}

package dadaxitong;

import java.util.Scanner;

public class Initail {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    Passenger passenger1 = new Passenger("奥迪A6",500,4);
    Passenger passenger2 = new Passenger("马自达6", 400, 4);
    Doubleusecar doubleusecar1 = new Doubleusecar("皮卡雪6", 400, 4, 2);
    Passenger passenger3 = new Passenger("金龙", 800, 20);
    Goodscar goodscar1 = new Goodscar("松花江", 400, 4);
    Goodscar goodscar2 = new Goodscar("依维柯", 1000, 20);
    System.out.println("欢迎使用答答租车系统:"+"\n您是否要租车:1是 0否");
    for (int i = 1; i < 100; i++) {
        Scanner scanner = new Scanner(System.in);
        int a= scanner.nextInt();
        if (a==1) {
            System.out.println("您可租车的类型及其价目表:"
                    +"\n序号"+" "+"汽车名称"+" "+"租金"+" "+"容量");      
            System.out.println("1"+" "+passenger1.getName()
                                +" "+passenger1.getPrice()+"/天"
                                +" "+"载人:"+passenger1.getBusload()+"人");
            System.out.println("2"+" "+passenger2.getName()
                                +" "+passenger2.getPrice()+"/天"
                                +" "+"载人:"+passenger2.getBusload()+"人");
            System.out.println("3"+" "+doubleusecar1.getName()
                                +" "+doubleusecar1.getPrice()+"/天"
                                +" "+"载人:"+doubleusecar1.getBusload()+"人"
                                +"载货"+doubleusecar1.getBurden()+"吨");
            System.out.println("4"+" "+passenger3.getName()+
                                " "+passenger3.getPrice()+"/天"+
                                " "+"载人:"+passenger3.getBusload()+"人");
            System.out.println("5"+" "+goodscar1.getName()+
                                " "+goodscar1.getPrice()+"/天"
                                +" "+"载货:"+goodscar1.getBurden()+"吨");
            System.out.println("6"+" "+goodscar2.getName()+
                                " "+goodscar2.getPrice()+"/天"
                                +" "+"载货:"+goodscar2.getBurden()+"吨");

    System.out.println("请输入您要租用汽车的数量:");
    int a1=scanner.nextInt();//租车辆数
    for (int j = 1; j <= a1; j++) {
        System.out.println("请输入第"+j+"辆车的序号:");
    int num =scanner.nextInt();//租车的序号
    int prices=0,busload=0,burden=0;
    String name1="";//储存载人车名
    String name2="";//储存载货车名
    switch (num) {
    case 1:
        name1 += passenger1.getName();
        prices += passenger1.getPrice();
        busload =+ passenger1.getBusload();
        break;
    case 2:
        name1 += passenger2.getName();
        prices += passenger2.getPrice();
        busload += passenger2.getBusload();
    case 3:
        name1 += doubleusecar1.getName();
        name2 += doubleusecar1.getName();
        prices += doubleusecar1.getPrice();
        busload += doubleusecar1.getBusload();
        burden += doubleusecar1.getBurden();
    case 4:
        name1 += passenger3.getName();
        prices += passenger3.getPrice();
        busload += passenger3.getBusload();
    case 5:
        name2 += goodscar1.getName();
        prices += goodscar1.getPrice();
        burden += goodscar1.getBurden();
    case 6:
        name2 += goodscar2.getName();
        prices += goodscar2.getPrice();
        burden += goodscar2.getBurden();
        break;
        }
    }
        System.out.println("请输入租车天数");
        int day = scanner.nextInt();//租车天数
        System.out.println("下面是您的账单:");
        System.out.println("您租的载人车有:");
        System.out.println(name1+"总载人数:"+busload+"人");
        System.out.println("您租的载货车有:");
        System.out.println(name2+"总载货量:"+burden+"吨");
        System.out.println("您租了:"+day+"天");
        int dayprices=prices;
        System.out.println("租车总价格:"+dayprices+"元");

    }else if (a==0) {
            System.out.println("谢谢光临,再见");
            break;
        }else {
            System.out.println("您的输入有误,请重新输入:1或者0 !");
        }
}

}
}