欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

java實(shí)現(xiàn)簡單汽車租賃系統(tǒng)

 更新時間:2021年01月20日 09:31:00   作者:小蘇(º﹃º )  
這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)簡單汽車租賃系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了java實(shí)現(xiàn)汽車租賃系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

一、使用技術(shù)

javaSE

二、實(shí)現(xiàn)功能

汽車租賃系統(tǒng)

具體要求如下:

使用面向?qū)ο蟮闹R實(shí)現(xiàn)一個汽車租賃系統(tǒng)

1.汽車租賃信息表如下

2.類和屬性

三、運(yùn)行效果圖


1.先創(chuàng)建一個汽車類作為父類,這里有汽車的公共屬性:

public class Automobile {//汽車類
  private String licensePlate;//車牌
  private String brand;//品牌
  private int rent;//租金

  public Automobile() {
  }

  public Automobile(String licensePlate, String brand, int rent) {
    this.licensePlate = licensePlate;
    this.brand = brand;
    this.rent = rent;
  }

  public String getLicensePlate() {
    return licensePlate;
  }

  public void setLicensePlate(String licensePlate) {
    this.licensePlate = licensePlate;
  }

  public String getBrand() {
    return brand;
  }

  public void setBrand(String brand) {
    this.brand = brand;
  }

  public int getRent() {
    return rent;
  }

  public void setRent(int rent) {
    this.rent = rent;
  }
}

2.創(chuàng)建一個轎車類,繼承汽車類的屬性

public class Car extends Automobile{//轎車
  private String model;//型號

  public Car(String model) {
    this.model = model;
  }

  public Car(String licensePlate, String brand, int rent, String model) {
    super(licensePlate, brand, rent);
    this.model = model;
  }

  public String getModel() {
    return model;
  }

  public void setModel(String model) {
    this.model = model;
  }
}

3.創(chuàng)建一個客車類,繼承汽車類的屬性

public class Passengercar extends Automobile{//客車
private String seatingCapacity;//座位數(shù)

  public Passengercar(String seatingCapacity) {
    this.seatingCapacity = seatingCapacity;
  }

  public Passengercar(String licensePlate, String brand, int rent, String seatingCapacity) {
    super(licensePlate, brand, rent);
    this.seatingCapacity = seatingCapacity;
  }

  public String getSeatingCapacity() {
    return seatingCapacity;
  }

  public void setSeatingCapacity(String seatingCapacity) {
    this.seatingCapacity = seatingCapacity;
  }
}

4.創(chuàng)建測試類,用于實(shí)現(xiàn)這個系統(tǒng)

import java.util.Scanner;

public class TestAutomobile {
  public static void main(String[] args) {


    Car c1 = new Car("京NY28588", "寶馬X6", 800, "1");
    Car c2 = new Car("京CNY3284", "寶馬550i", 600, "1");
    Car c3 = new Car("京NT37465", "別克林蔭大道", 300, "1");
    Car c4 = new Car("京NT969968", "別克GL8", 600, "1");

    Passengercar p1 = new Passengercar("京6566754", "金杯,16座", 800, "2");
    Passengercar p2 = new Passengercar("京8696997", "金龍,16座", 800, "2");
    Passengercar p3 = new Passengercar("京9696996", "金杯,34座", 1500, "2");
    Passengercar p4 = new Passengercar("京8696998", "金龍,34座", 1500, "2");
    Scanner sc = new Scanner(System.in);

    System.out.println("***********************歡迎光臨秋名山守望者汽車租賃公司***********************");
    while (true){
      System.out.println("1、轎車  2、客車");
      System.out.println("請選擇你要租賃的汽車類型:");
      String a=sc.next();
      if (a.equals("1")){//轎車
        System.out.println("請選擇你要租賃的汽車品牌:1、別克 2、寶馬");
        String a1=sc.next();
        if (a1.equals("2")){//寶馬
          System.out.println("請選擇你要租賃的汽車類型:1、X6 2、550i");
          String a2=sc.next();
          if (a2.equals("2")){//550i
            System.out.println("請選擇你要租賃的天數(shù)");
            double a3=sc.nextInt();
            System.out.println("分配給您的汽車牌號是:"+c2.getLicensePlate());
            System.out.print("您需要支付的租賃費(fèi)用是:");
            if (a3>7&&a3<=30){
              System.out.println(c2.getRent()*a3*0.9+"元");
            }else if(a3>30&&a3<=150){
              System.out.println(c2.getRent()*a3*0.8+"元");
            }else {
              System.out.println(c2.getRent()*a3*0.7+"元");
            }
          }else {//x6
            System.out.println("請選擇你要租賃的天數(shù)");
            double a3=sc.nextInt();
            System.out.println("分配給您的汽車牌號是:"+c1.getLicensePlate());
            System.out.print("您需要支付的租賃費(fèi)用是:");
            if (a3>7&&a3<=30){
              System.out.println(c1.getRent()*a3*0.9+"元");
            }else if(a3>30&&a3<=150){
              System.out.println(c1.getRent()*a3*0.8+"元");
            }else {
              System.out.println(c1.getRent()*a3*0.7+"元");
            }
          }
        }else {//別克
          System.out.println("請選擇你要租賃的汽車類型:1、林蔭大道 2、GL8");
          String a2=sc.next();
          if (a2.equals("2")){//GL8
            System.out.println("請選擇你要租賃的天數(shù)");
            double a3=sc.nextInt();
            System.out.println("分配給您的汽車牌號是:"+c4.getLicensePlate());
            System.out.print("您需要支付的租賃費(fèi)用是:");
            if (a3>7&&a3<=30){
              System.out.println(c4.getRent()*a3*0.9+"元");
            }else if(a3>30&&a3<=150){
              System.out.println(c4.getRent()*a3*0.8+"元");
            }else {
              System.out.println(c4.getRent()*a3*0.7+"元");
            }
          }else {//別克林蔭大道
            System.out.println("請選擇你要租賃的天數(shù)");
            double a3=sc.nextInt();
            System.out.println("分配給您的汽車牌號是:"+c3.getLicensePlate());
            System.out.print("您需要支付的租賃費(fèi)用是:");
            if (a3>7&&a3<=30){
              System.out.println(c3.getRent()*a3*0.9+"元");
            }else if(a3>30&&a3<=150){
              System.out.println(c3.getRent()*a3*0.8+"元");
            }else {
              System.out.println(c3.getRent()*a3*0.7+"元");
            }
          }
        }


     /* Passengercar p1 = new Passengercar("京6566754", "金杯", 800, "2");
      Passengercar p2 = new Passengercar("京8696997", "金龍", 800, "2");
      Passengercar p3 = new Passengercar("京9696996", "金杯", 1500, "2");
      Passengercar p4 = new Passengercar("京8696998", "金龍", 1500, "2");
*/
      }else {//客車
        System.out.println("請選擇你要租賃的汽車品牌:1、金龍 2、金杯");
        String a1=sc.next();
        if (a1.equals("1")){//金龍
          System.out.println("請選擇你要租賃的汽車座位數(shù):1、16座 2、34座");
          String a2=sc.next();
          if (a2.equals("1")){//16座
            System.out.println("請選擇你要租賃的天數(shù)");
            double a3=sc.nextInt();
            System.out.println("分配給您的汽車牌號是:"+p2.getLicensePlate());
            System.out.print("您需要支付的租賃費(fèi)用是:");
            if (a3>=3&&a3<7){
              System.out.println(p2.getRent()*a3*0.9+"元");
            }else if(a3>=7&&a3<30){
              System.out.println(p2.getRent()*a3*0.8+"元");
            }else if (a3>=30&&a3<150){
              System.out.println(p2.getRent()*a3*0.7+"元");
            }else {
              System.out.println(p2.getRent()*a3*0.6+"元");
            }
          }else {//34
            System.out.println("請選擇你要租賃的天數(shù)");
            double a3=sc.nextInt();
            System.out.println("分配給您的汽車牌號是:"+p4.getLicensePlate());
            System.out.print("您需要支付的租賃費(fèi)用是:");
            if (a3>=3&&a3<7){
              System.out.println(p4.getRent()*a3*0.9+"元");
            }else if(a3>=7&&a3<30){
              System.out.println(p4.getRent()*a3*0.8+"元");
            }else if (a3>=30&&a3<150){
              System.out.println(p4.getRent()*a3*0.7+"元");
            }else {
              System.out.println(p4.getRent()*a3*0.6+"元");
            }
          }
        }else {//金杯
          System.out.println("請選擇你要租賃的汽車座位數(shù):1、16座 2、34座");
          String a2=sc.next();
          if (a2.equals("1")){//16座
            System.out.println("請選擇你要租賃的天數(shù)");
            double a3=sc.nextInt();
            System.out.println("分配給您的汽車牌號是:"+p1.getLicensePlate());
            System.out.print("您需要支付的租賃費(fèi)用是:");
            if (a3>=3&&a3<7){
              System.out.println(p1.getRent()*a3*0.9+"元");
            }else if(a3>=7&&a3<30){
              System.out.println(p1.getRent()*a3*0.8+"元");
            }else if (a3>=30&&a3<150){
              System.out.println(p1.getRent()*a3*0.7+"元");
            }else {
              System.out.println(p1.getRent()*a3*0.6+"元");
            }
          }else {//34
            System.out.println("請選擇你要租賃的天數(shù)");
            double a3=sc.nextInt();
            System.out.println("分配給您的汽車牌號是:"+p3.getLicensePlate());
            System.out.print("您需要支付的租賃費(fèi)用是:");
            if (a3>=3&&a3<7){
              System.out.println(p3.getRent()*a3*0.9+"元");
            }else if(a3>=7&&a3<30){
              System.out.println(p3.getRent()*a3*0.8+"元");
            }else if (a3>=30&&a3<150){
              System.out.println(p3.getRent()*a3*0.7+"元");
            }else {
              System.out.println(p3.getRent()*a3*0.6+"元");
            }
          }
        }

      }
      System.out.println();
      System.out.println();
      System.out.println("是否還要繼續(xù)選車 1繼續(xù) 2終止");
      String x=sc.next();
      if (x.equals("2")){
        System.out.println("歡迎下次光臨!");
        break;
      }
      System.out.println();
      System.out.println();
    }


  }

}

1.轎車的實(shí)現(xiàn)

2.客車的實(shí)現(xiàn)

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論