汽车租赁系统测试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测试-----达达租车系统的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 出租车系统java_基于WEB的JAVA
- 下一篇: APP使用monkey进行稳定性测试过程