- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCarApp.java
More file actions
Latest commit
95 lines (79 loc) · 2.79 KB
/
Copy pathCarApp.java
File metadata and controls
95 lines (79 loc) · 2.79 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
*/
packagecarapp;
importjava.util.Scanner;
/**
*
* @author tung
*/
publicclassCarApp {
/**
* @param args the command line arguments
*/
publicstaticvoidmain(String[] args) {
// TODO code application logic here
Scannerscanner = newScanner(System.in);
Stringinput;
Carcar;
while(true)
{
System.out.print("Enter car model(C, E, CS) or quit to exit: ");
input = scanner.nextLine();
if ("quit".equalsIgnoreCase(input))
{
break;
}
switch(input.toUpperCase())
{
case"C":
car = newmodel_C();
break;
case"E":
car = newmodel_E();
break;
case"CS":
car = newmodel_CS();
break;
default:
System.out.println("Invalid input.");
continue;
}
System.out.print("Option (V-8, V-12, Sun Roof, Baupunkt New York 800 Radio (Radio), Spare Tire, Oversized Gas Tank(OGT), done): ");
while(!(input = scanner.nextLine()).equalsIgnoreCase("done"))
{
System.out.print("Option (V-8, V-12, Sun Roof, Baupunkt New York 800 Radio (Radio), Spare Tire, Oversized Gas Tank(OGT), done): ");
switch (input.toLowerCase())
{
case"v-8":
car = newV8Engine(car);
break;
case"v-12":
car = newV12Engine(car);
break;
case"sun roof":
car = newsunRoof(car);
break;
case"radio":
car = newRadio(car);
break;
case"spare tire":
car = newspareTire(car);
break;
case"ogt":
car = newoversizedGasTank(car);
break;
default:
System.out.println("Invalid Input");
continue;
}
}
System.out.println("New Order:");
System.out.printf(" %s%n",car.getInfo());
System.out.printf(" Cost: $%,d%n", car.getCost());
System.out.println ("End Order");
}
scanner.close();
}
}