-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPassengerMenus.java
114 lines (83 loc) · 2.78 KB
/
PassengerMenus.java
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.ArrayList;
public class PassengerMenus {
/**
* @param args
* @return
* @throws IOException
*/
public static void main(String[] args) throws IOException {
boolean run = true;
while (run){
Scanner input = new Scanner(System.in);
System.out.println("============ Menu 1 ============");
System.out.print("Enter option(1, 2, 3): ");
String option = input.nextLine();
Integer option1 = Integer.valueOf(option);
if(option1 == 3){
System.exit(0);
}
System.out.print("Enter your first name: ");
String first = input.nextLine();
System.out.print("Enter your last name: ");
String last = input.nextLine();
if(option1 == 1){
System.out.println("newPassenger: " + first + " "+ last);
}
if(option1 == 2){
System.out.println("findPassenger: " + first + " "+ last);
}
System.out.println("============ Menu 2 ============");
System.out.print("Enter option(1, 2, 3, 4): ");
String option2 = input.nextLine();
int option3;
option3 = Integer.valueOf(option2);
if (option3 == 1){
System.out.print("Enter <Originating airport> (three letter code): ");
String origin = input.nextLine();
System.out.print("Enter <Destination airport> (three letter code): ");
String destin = input.nextLine();
System.out.println("findAvalibleFlig1htPlans: " + origin + " "+ destin);
break;
}
if (option3 ==4){
run=true;
}
if (option3 ==2){
get();
break;
}
if (option3 ==3){
break;
}
}
}
private static String[] codes = {"GNV", "BTR", "MCO", "MIA", "ATL", "IAH", "LAX", "JFK", "LGA", "ORD", "BOS", "ANC", "DEN", "SLC", "SFO", "IAD", "SEA", "OKC"};
// Used internally.
private static int getRandomInt(int min, int max)
{
int x; // We're going to divide integers.
// Don't allow y == 0!
x = (int) (Math.random() * (max - min) + min);
return x;
}
/**
* Gets a randomly-generated itinerary - a array of sequential airport code pairings.
* @return
*/
public static String[] get()
{
ArrayList<String> codeList = new ArrayList<String>(Arrays.asList(codes));
Collections.shuffle(codeList);
int count = getRandomInt(1, 6);
String[] itinerary = new String[count];
for(int i=0; i < count; i++)
{
itinerary[i] = codeList.get(i) + "-" + codeList.get(i+1);
}
return itinerary;
}
}