日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

汽车租赁系统测试java,Java测试-----达达租车系统

發布時間:2023/12/3 windows 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 汽车租赁系统测试java,Java测试-----达达租车系统 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

測試類

package coom.car_rental.java;

import java.util.Scanner;

/*

* 這是測試主類

*/

public class CarRental implements cars{

public static void main(String[] args) {

// TODO 自動生成的方法存根

System.out.println("歡迎使用達達租車系統!");

System.out.println("請問您是否需要租車? 0-否 1-是 ");

Scanner sc = new Scanner(System.in);

int op1 = sc.nextInt();

switch (op1) {

case 0:

System.out.println("歡迎您使用達達租車系統!" + "\n" +

"期待您的再次使用!" + "\n" + "再見!");

System.exit(0);

case 1:

System.out.println("您可租用車的數量及價格表");

System.out.println("序號"+ "\t車名" + "\t車的載客量(人)" + "\t車的載貨量(噸)"

+ "\t車的價格(天/元)");

//循環輸出車的信息

for(int i = 0;i < cars.length;i ++) {

System.out.println((i + 1) +"\t"+ cars[i]);

}

break;

default:

System.out.println("輸入錯誤!");

break;

}

double price = 0;//總的價格

int allpeople = 0;//總的人數

int allloads = 0;//總的載貨量

System.out.println("請輸入你需要租車的數量");

Scanner snb = new Scanner(System.in);

int cnb = snb.nextInt();

Car[] rentCar = new Car[cnb];

for(int i=0;i < cnb;i ++) {

System.out.println("請輸入您第" + (i + 1) +"的租車序號" );

int number = snb.nextInt();

rentCar[i] =cars[number - 1];

}

System.out.println("請輸入您的租車天數");

int dayNumber = snb.nextInt();

System.out.println("\t***************您的賬單如下***********");

System.out.println("您選的載人客車有:");

for(int i = 0;i < cnb;i ++) {

if(rentCar[i].busload != 0) {

System.out.println(rentCar[i].name + "\t" + rentCar[i].busload);

}

allpeople = allpeople + rentCar[i].busload;

}

System.out.println("一共有" + allpeople + "人");

System.out.println("您的載貨汽車有:");

for(int i = 0;i < cnb;i ++) {

if(rentCar[i].burden != 0) {

System.out.println(rentCar[i].name + "\t" + rentCar[i].burden);

}

allloads = allloads + rentCar[i].burden;

}

System.out.println("一共載貨" + allloads + "噸" );

for(int i =0;i < cnb;i ++) {

price = price + rentCar[i].dailyRent * dayNumber;

}

System.out.println("您總的價格是:" + price);

}

}

Car類

package coom.car_rental.java;

public abstract class Car {

public String name;//車的名字

public int carNumber;//租車數量

public int busload;//載客量

public int burden;//載貨量

public double dailyRent;//日租金

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public int getCarNumber() {

return carNumber;

}

public void setCarNumber(int carNumber) {

this.carNumber = carNumber;

}

public int getBusload() {

return busload;

}

public void setBusload(int busload) {

this.busload = busload;

}

public int getBurden() {

return burden;

}

public void setBurden(int burden2) {

this.burden = burden2;

}

public double getDailyRent() {

return dailyRent;

}

public void setDailyRent(double dailyRent) {

this.dailyRent = dailyRent;

}

}

車庫類

package coom.car_rental.java;

public interface cars {

Car[] cars = {

new PassengerCar("奧迪A4", 4, 500),

new PassengerCar("馬自達6", 4, 400),

new PickupTruck("皮卡雪6", 4, 2, 450),

new PassengerCar("金龍", 20, 800),

new Truck("松花江", 4, 400),

new Truck("依維柯", 20, 1000)};

}

卡車類

package coom.car_rental.java;

/*

* 這是貨車類,載貨的

*/

public class Truck extends Car {

public Truck(String name, int burden, double dailyRent) {

// TODO 自動生成的構造函數存根

this.setName(name);

this.setBurden(burden);

this.setDailyRent(dailyRent);

}

public String toString() {

return this.getName() + "\t" +this.getBurden() + "\t\t" + this.getDailyRent();

}

}

客車類

package coom.car_rental.java;

/*

* 這是客車類,載人的

*/

public class PassengerCar extends Car {

public PassengerCar(String name, int busload,double dailyRent) {

// TODO 自動生成的構造函數存根

this.setName(name);

this.setBusload(busload);

this.setDailyRent(dailyRent);

}

public String toString() {

return this.getName() +"\t" + this.getBusload() + "\t\t\t\t" + this.getDailyRent();

}

}

皮卡類

package coom.car_rental.java;

/*

* 這是皮卡車類,既可以載人也可以載貨

*/

public class PickupTruck extends Car {

public PickupTruck(String name, int busload, int burden, double dailyRent) {

// TODO 自動生成的構造函數存根

this.setName(name);

this.setBusload(busload);

this.setBurden(burden);

this.setDailyRent(dailyRent);

}

public String toString () {

return this.getName() + "\t" + this.getBusload() + "\t\t"

+ this.getBurden() + "\t\t" + this.getDailyRent();

}

}

總結

以上是生活随笔為你收集整理的汽车租赁系统测试java,Java测试-----达达租车系统的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。