激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達(dá)式|C/C++|IOS|C#|Swift|Android|JavaScript|易語言|

服務(wù)器之家 - 編程語言 - Java教程 - java實(shí)現(xiàn)簡單租車系統(tǒng)

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

2021-07-13 12:25淺然_ Java教程

這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)簡單租車系統(tǒng),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

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

這也是參考了mooc上的一個(gè)基礎(chǔ)項(xiàng)目,所以拿來寫一下。不過我的demo肯定有不好或者錯(cuò)誤的地方,歡迎指出

1、項(xiàng)目功能/需求

a、展示所有可租車輛
b、選擇車型、租車量
c、展示租車清單,包含:總金額、總載貨量、總載客量

2、項(xiàng)目系統(tǒng)uml圖

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

3、項(xiàng)目源碼demo

car類

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package car.rental;
 
public class car {
 private string name;
 private int rent;
 private int passenger;
 private double volume;
 public string getname() {
 return name;
 }
 public void setname(string name) {
 this.name = name;
 }
 public int getrent() {
 return rent;
 }
 public void setrent(int rent) {
 this.rent = rent;
 }
 public int getpassenger() {
 return passenger;
 }
 public void setpassenger(int passenger) {
 this.passenger = passenger;
 }
 public double getvolume() {
 return volume;
 }
 public void setvolume(double volume) {
 this.volume = volume;
 }
 
}

truck類

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package car.rental;
 
public class truck extends car {
 private string name;
 private int rent;
 private double volume;
 public truck(string name,int rent,double volume)
 {
 this.name=name;
 this.rent=rent;
 this.volume=volume;
 }
 public string getname() {
 return name;
 }
 public void setname(string name) {
 this.name = name;
 }
 public int getrent() {
 return rent;
 }
 public void setrent(int rent) {
 this.rent = rent;
 }
 public double getvolume() {
 return volume;
 }
 public void setvolume(double volume) {
 this.volume = volume;
 }
 
}

coach類

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package car.rental;
 
public class coach extends car {
 
 private string name;
 private int rent;
 private int passenger;
 public coach(string name,int rent,int passenger) {
 this.name=name;
 this.passenger=passenger;
 this.rent=rent;
 }
 public int getpassenger() {
 return passenger;
 }
 public void setpassenger(int passenger) {
 this.passenger = passenger;
 }
 public string getname() {
 return name;
 }
 public void setname(string name) {
 this.name = name;
 }
 public int getrent() {
 return rent;
 }
 public void setrent(int rent) {
 this.rent = rent;
 }
}

pickup類

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package car.rental;
 
public class pickup extends car {
 private string name;
 private int rent;
 private int passenger;
 private double volume;
 public pickup(string name,int rent,int passenger,double volume)
 {
 this.name=name;
 this.passenger=passenger;
 this.rent=rent;
 this.volume=volume;
 }
 public int getpassenger() {
 return passenger;
 }
 public void setpassenger(int passenger) {
 this.passenger = passenger;
 }
 public double getvolume() {
 return volume;
 }
 public void setvolume(double volume) {
 this.volume = volume;
 }
 public string getname() {
 return name;
 }
 public void setname(string name) {
 this.name = name;
 }
 public int getrent() {
 return rent;
 }
 public void setrent(int rent) {
 this.rent = rent;
 }
 
}

測試類

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package car.rental;
 
import java.util.scanner;
 
public class main_car {
 
 public static void main(string[] args) {
 // todo auto-generated method stub
 /*****創(chuàng)建車對象*******/
 /*car tru=new truck("拉絲貨車",200,1.1);
 car coa=new coach("法法客車",150,20);
 car pic=new pickup("無名皮卡車",300,4,0.5);*/
 car[] allcar= {new truck("拉絲貨車",200,1.1),new coach("法法客車",150,20),
   new pickup("無名皮卡車",300,4,0.5)};
 
 system.out.println("請問您是否要租車:1.是 2.否");
 scanner scan=new scanner(system.in);
 string input=scan.next();
 if(input.equals("1"))
 {
  int all_rent = 0;//總租金
  int all_passenger=0;//總載客
  double all_volume=0.0;//總載貨
  system.out.println("您可租車的類型及其價(jià)目");
  system.out.println("序號\t汽車名稱\t租金\t容量\t");
  for(int i=0;i<allcar.length;i++)
  {
  if(allcar[i] instanceof truck)
  {
   system.out.println((i+1)+"\t"+allcar[i].getname()+"\t"+allcar[i].getrent()+"\t"+"載貨:"+allcar[i].getvolume());
  }
  if(allcar[i] instanceof coach)
  {
   system.out.println((i+1)+"\t"+allcar[i].getname()+"\t"+allcar[i].getrent()+"\t"+"載客:"+allcar[i].getpassenger());
  }
  if(allcar[i] instanceof pickup)
  {
   system.out.println((i+1)+"\t"+allcar[i].getname()+"\t"+allcar[i].getrent()+"\t"+"載客:"+allcar[i].getpassenger()+"載貨:"+allcar[i].getvolume());
  }
  }
  system.out.println("請輸入您要租車的數(shù)量");
  int sum=scan.nextint();
  int car_order;
  for(int j=0;j<sum;j++)
  {
  system.out.print("你要租的第"+(j+1)+"輛車的序號是:");
  car_order=scan.nextint();
  system.out.println();
  if(allcar[car_order-1] instanceof truck)
  {
   all_rent+=allcar[car_order-1].getrent();
   all_volume+=allcar[car_order-1].getvolume();
  }
  if(allcar[car_order-1] instanceof coach)
  {
   all_rent+=allcar[car_order-1].getrent();
   all_passenger+=allcar[car_order-1].getpassenger();
  }
  if(allcar[car_order-1] instanceof pickup)
  {
   all_rent+=allcar[car_order-1].getrent();
   all_passenger+=allcar[car_order-1].getpassenger();
   all_volume+=allcar[car_order-1].getvolume();
  }
  }
  system.out.println("您的總租金是:"+all_rent);
  system.out.println("您的總載貨是:"+all_volume);
  system.out.println("您的總載客是:"+all_passenger);
 }
 
 }
 
}

4、項(xiàng)目命令行演示結(jié)果

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

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

原文鏈接:https://blog.csdn.net/w_linux/article/details/79181092

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 懂色粉嫩av久婷啪 | 精品久久久久久久久久久下田 | 日韩中文字幕三区 | 亚洲成人在线视频网 | 成人毛片在线 | 狠狠色噜噜狠狠狠米奇9999 | 成人在线视频一区 | 色七七网站 | 欧美精品免费一区二区三区 | 久久亚洲一区二区三区成人国产 | 午夜精品在线视频 | 午夜人体| 亚洲自拍第一 | 国产亚洲在线 | 国产一区二区影视 | 亚洲第五色综合网 | 激情网站免费观看 | 中文字幕一二三区芒果 | 国av在线 | 国产成人高潮免费观看精品 | 高清一区二区在线观看 | 日本成人在线免费 | 欧美亚洲综合网 | 欧美18—19sex性护士中国 | 午夜亚洲影院 | 欧美一级特黄aaaaaa在线看首页 | 国产精品久久77777 | 青青草最新网址 | 免费国产wwwwwww网站 | 超碰人人做人人爱 | 久草视频在线看 | 国产女同疯狂激烈互摸 | 国产男女 爽爽爽爽视频 | 精品成人国产在线观看男人呻吟 | 欧美一级片 在线播放 | 国产精品久久久久久久av | 亚洲人成在线播放 | 一级在线免费观看视频 | 久色视频| 91精品国产综合久久婷婷香蕉 | 羞羞视频免费网站含羞草 |