汽车租赁

Posted Beautiful program

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了汽车租赁相关的知识,希望对你有一定的参考价值。

import java.util.Scanner;
class Java继承 
{
    public static void main(String[] args) 
    {
        Company company = new Company();
        company.name = "江工租赁公司";
        company.limousine = new Limousine();
        company.passengerCar = new PassengerCar();
        company.fun();
    }
}

class Company
{
    String name;
    Limousine  limousine;
    PassengerCar passengerCar;
    public void fun(){
        System.out.println("\t\t欢迎你拉来到"+name);
        System.out.println("\n\n本公司有:\n1.轿车\n2.客车");
        System.out.println("\n温馨提醒:输入1或2即可");
        Scanner sc = new Scanner(System.in);
        System.out.print("\n请输入你想租赁的车种: ");
        int car = sc.nextInt();
        switch(car){
            case 1 : limousine.l();break;
            case 2 : passengerCar.p();break;
            default : System.out.print("\n你的输入有误!");
        }        
    }
    public void rent(int price){
        Scanner sc = new Scanner(System.in);
        System.out.print("\n请输入你想租赁多少天: ");
        int days = sc.nextInt();
        System.out.println("\n你好!租赁总价为: "+price*days);
    }
}

class Limousine extends Company
{
    String[] model;
    int[] price;
    public void l(){
        String[] str = {"1.别克商务舱GL8","2.宝马550i","3.别克林荫大道"};
        int [] number = {600,500,300};
        model = str;
        price = number;
        System.out.println("\n轿车拥有的车型编号如下:");
        for (String i:model)
        {
            System.out.println("\n"+i);
        }
        
        System.out.print("\n请输入你想租赁的车型编号: ");
        Scanner sc = new Scanner(System.in);
        int temp = sc.nextInt()-1;
        rent(price[temp]);
    }
}

class PassengerCar extends Company
{
    String[] model;
    int[] price;
    public void p(){
        String[] str = {"1.金杯客车","2.金龙客车"};
        int [] number = {800,1500};
        model = str;
        price = number;
        System.out.println("\n客车拥有的车型编号如下:");
        for (String i:model)
        {
            System.out.println("\n"+i);
        }
        
        System.out.print("\n请输入你想租赁的车型编号: ");
        Scanner sc = new Scanner(System.in);
        int temp = sc.nextInt()-1;
        rent(price[temp]);
    }
}

 

以上是关于汽车租赁的主要内容,如果未能解决你的问题,请参考以下文章

Unity常用组件参数详解

微信小程序代码片段

汽车国标代码:国IV是指国标4还是国标5?

VSCode自定义代码片段——CSS选择器

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

一部汽车数亿行代码!软件是如何吞噬汽车的?