租车系统

???又水?说好的反射呢?说好的泛型数组列表呢?鸽了,鸽了,就是这么任性。
package 租车系统;

import java.util.Scanner;

/**
*1轿车
* 奥迪Q3    500元/天
* 奥迪Q7    700元/天
* 宝马X3    200元/天
* 奥拓A1    300元/天
*
* 2.客车
* 金杯12坐    小于等于16座,800元/天
* 金龙24座    大于等于16座,1200元/天
*/

public class Test {
    public static void main(String[] args) {
        System.out.println("******************************租车系统***********************");
        Scanner input = new Scanner(System.in);

        Person person = new Person();
        System.out.println("请输入你的姓名:");
        person.setName(input.next());
        System.out.println("请输入你的联系方式:");
        person.setPhone(input.next());
        int i = 0;
        motorVehicles[] motor = new motorVehicles[100];

        while (true){
            System.out.println("---------------------------------------");
            System.out.println("请输入想要租借的车型(1.轿车 2.客车 0.退出");
            int chioce = input.nextInt();
 

            if (chioce==1)
            {
                System.out.println("请选着车辆(1.奥迪Q3 2.奥迪Q7 3.宝马X3 4.奥拓A1");
                int num = input.nextInt();

                switch (num)
                {
                    case 1:
                       motor[i++]   = new Car("皖A11111","奥迪",carCountant.AUDI_Q3);
                        break;
                    case 2:
                        motor[i++]  = new Car("皖A22222","奥迪",carCountant.AUDI_Q7);
                        break;
                    case 3:
                        motor[i++]  = new Car("皖A33333","宝马",carCountant.BMW_X3);
                        break;
                    case 4:
                        motor[i++]  = new Car("皖A44444","奥拓",carCountant.ALTO_A1);
                        break;
                }
            }
            else if (chioce==2)
            {
                System.out.println("请选啧车辆:(1.金杯 2.金龙 3.退出");
                int num = input.nextInt();

                switch (num){
                    case 1:
                        motor[i++] = new Bus("皖A55555","金杯12座",12);
                        break;
                    case 2:
                        motor[i++] = new Bus("皖A66666","金龙24座",24);
                        break;
                }
            }
            else if (chioce == 0)
            {
                break;
            }
            else {
                System.out.println("输入有误");
            }
        }
        System.out.println("请输入租借天数:");
        int day = input.nextInt();

        System.out.println("-----------------------------------------------");

        System.out.println("客户"+ person.getName() + "您租的车辆信息如下:");
        System.out.println("车牌号\t\t品牌");
        System.out.println("-----------------------------------------------");
        double totalMoney = 0.0;

        for (int j = 0; j < i; j++)
        {
            totalMoney += motor[j].calcRant(day);
            System.out.println(motor[j].getNo() + "\t\t" +motor[j].getMultitude());
        }
        System.out.println("租借天数:"+ day +"天\t总租金:"+totalMoney);
    }
}

package 租车系统;

public class carCountant {
    public static final String AUDI_Q3 = "Q3";
    public static final String AUDI_Q7 = "Q7";
    public static final String BMW_X3 = "X3";
    public static final String ALTO_A1 = "A1";

}

package 租车系统;

public abstract class motorVehicles {
     String multitude;
     String no;

    public motorVehicles(String multitude, String no) {
    }

    public String getMultitude() {
        return multitude;
    }

    public void setMultitude(String multitude) {
        this.multitude = multitude;
    }

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }
    public abstract int calcRant(int day);
}

package 租车系统;

public class Car extends motorVehicles{
    private String type;

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Car(String no,String multitude,String type) {
        super(no,multitude);
        this.type = type;
    }

    double sum = 0;
    public int calcRant(int day)
    {
        if (type.equals(carCountant.AUDI_Q3))
        {
            sum = 500*day;
        }
        if(type.equals(carCountant.AUDI_Q7))
        {
            sum=700*day;
        }
        if (type.equals(carCountant.BMW_X3))
        {
            return 300*day;
        }
        if (type.equals(carCountant.ALTO_A1))
        {
            return 800*day;
        }

        return 0;
    }
}

package 租车系统;

public class Car extends motorVehicles{
    private String type;

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Car(String no,String multitude,String type) {
        super(no,multitude);
        this.type = type;
    }

    double sum = 0;
    public int calcRant(int day)
    {
        if (type.equals(carCountant.AUDI_Q3))
        {
            sum = 500*day;
        }
        if(type.equals(carCountant.AUDI_Q7))
        {
            sum=700*day;
        }
        if (type.equals(carCountant.BMW_X3))
        {
            return 300*day;
        }
        if (type.equals(carCountant.ALTO_A1))
        {
            return 800*day;
        }

        return 0;
    }
}

package 租车系统;

public class Bus extends motorVehicles{
    private int seatCount = 0;

    public int getSeatCount() {
        return seatCount;
    }

    public void setSeatCount(int seatCount) {
        this.seatCount = seatCount;
    }

    public Bus(String no,String multitude , int seatCount) {
        super(no,multitude);
        this.seatCount = seatCount;
    }
    double sum = 0;
    public int calcRant(int day) {
        if (seatCount <= 16)
        {
            sum = 800*day;
        }
        if (seatCount>16)
        {
            sum = 1600*day;
        }
        return 0;
    }
}

 

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值