Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Airline Reservation Version 2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
daniel.tang
Airline Reservation Version 2
Commits
522b2083
Commit
522b2083
authored
Dec 05, 2019
by
daniel.tang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
My program assignment
parent
70c34c56
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
374 additions
and
0 deletions
+374
-0
Airline_Program_v2.java
Airline_Program_v2.java
+374
-0
No files found.
Airline_Program_v2.java
0 → 100644
View file @
522b2083
package
program
;
import
static
java
.
lang
.
System
.
out
;
import
java.lang.reflect.Array
;
// not in use....
import
java.util.Scanner
;
import
java.util.ArrayList
;
public
class
Airline_Program_v2
{
//Array
static
ArrayList
<
String
>
firstName
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
lastName
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
origin
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
destination
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
seatBook
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
travelingClass
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
choosenFlight
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
boardName
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
boardLast
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
boardOrigins
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
boardDestination
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
boardseatBook
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
travelsClass
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
boardFlight
=
new
ArrayList
<
String
>();
static
Scanner
input
=
new
Scanner
(
System
.
in
);
// LIKE OOP BUT NOT BULLSHIT WITH LONG ASS CODING IN C#
// without static it I would have to copy & paste the Scanner to all voids
static
int
x
,
y
;
// allow to use all without copy & paste & waste of time ez pz
// Rewrite the program to make it more efficent and trying to make it work.
public
static
void
main
(
String
[]
args
)
{
// Data Example
firstName
.
add
(
"Daniel"
);
lastName
.
add
(
"Tang"
);
origin
.
add
(
"Hong Kong"
);
destination
.
add
(
"Japan"
);
seatBook
.
add
(
"1"
);
travelingClass
.
add
(
"First"
);
// Interface
while
(
true
)
{
out
.
print
(
"Enter 'F' to display flights OR enter 'C' to arrange your flight OR 'E' to exit. > "
);
String
user
=
input
.
next
();
if
(
user
.
equals
(
"F"
))
{
flightAvaliable
();
// Display flight > Line 72
}
if
(
user
.
equals
(
"C"
))
{
booking
();
// Moves to booking void
}
if
(
user
.
equals
(
"E"
))
{
System
.
exit
(
0
);
// terminates program
}
}
// End While loop > Interface > Line 46
}
// End Mains > Line 34
// flightAvaliable
public
static
void
flightAvaliable
()
{
out
.
println
();
int
l
=
28
;
// from 28
do
{
System
.
out
.
println
(
"FL-"
+
l
);
//
l
--;
}
while
(
l
>
1
);
out
.
println
();
}
// End flightAvaliable > Line 73
// booking
public
static
void
booking
()
{
// Menu
out
.
println
(
"Please enter > \n"
+
" \n"
+
"O - Start Documentation \n"
+
"K - Print Boarding Passs \n"
+
"OR type 'Exit' to exit the application. \n"
+
" \n"
+
""
);
String
custoemrChoice
=
input
.
next
();
// User input > STRING ONLY
// Switch case
switch
(
custoemrChoice
)
{
case
"O"
:
// Allows options of capital or under case...
case
"o"
:
documentSwitch
();
break
;
case
"k"
:
case
"K"
:
boardingSwitch
();
break
;
case
"m"
:
case
"M"
:
//managementRole();
break
;
case
"Exit"
:
case
"exit"
:
break
;
}
}
// End booking > Line 85
// documentSwitch > line 109
private
static
void
documentSwitch
()
{
out
.
print
(
"Please enter your first name > "
);
String
firstName
=
input
.
next
();
// firstname = ID CAP SPECIFIC
out
.
println
();
out
.
print
(
"Please enter your last name > "
);
String
lastName
=
input
.
next
();
// lastname = ID CAP SPECIFIC
out
.
println
();
out
.
print
(
"Please enter your origin > "
);
String
origin
=
input
.
next
();
// origin = ID CAP SPECIIC
out
.
println
();
out
.
print
(
"Please enter your destination > "
);
String
destination
=
input
.
next
();
// origin = ID CAP SPECIFIC
out
.
println
();
// To storage
boardName
.
add
(
firstName
);
boardLast
.
add
(
lastName
);
boardOrigins
.
add
(
origin
);
boardDestination
.
add
(
destination
);
//travelsClass.add(travelsClass);
//boardClassfirst.add(Classfirst);
// Travel Class starts here
out
.
println
(
"--------------------------------------------------------"
);
out
.
println
(
"This section is the travel class."
);
out
.
println
(
"--------------------------------------------------------"
);
out
.
println
();
out
.
println
(
"--First---+----Business----+-------Economy-----------\n"
+
"[01] [10] | [19] [28] [37] | [46] [55] [64] [73] [82]\n"
+
"[02] [11] | [20] [29] [38] | [47] [56] [65] [74] [83]\n"
+
"[03] [12] | [21] [30] [39] | [48] [57] [66] [75] [84]\n"
+
"-----------------------------------------------------\n"
+
"[04] [13] | [22] [31] [40] | [49] [58] [67] [76] [85]\n"
+
"[05] [14] | [23] [32] [41] | [50] [59] [68] [77] [86]\n"
+
"[06] [15] | [24] [32] [42] | [51] [60] [69] [78] [87]\n"
+
"-----------------------------------------------------\n"
+
"[07] [16] | [25] [33] [44] | [52] [61] [70] [79] [88]\n"
+
"[08] [17] | [26] [34] [45] | [53] [62] [71] [80] [89]\n"
+
"[09] [18] | [27] [35] [46] | [54] [63] [72] [81] [90]\n"
);
out
.
println
();
out
.
println
();
out
.
println
(
"Note if you want seats 1 - 9, please enter,"
+
"0 1 to have seat 1."
);
out
.
println
();
out
.
println
();
// THIS TAKEN SO LONG TO FIGUER THIS SHIT OUT INSTEAD OF GOING LOOP AFTER FINISHING (09) [9 1] I thought would be 10... BIG BRAIN LMAO.
// Look at
String
board
[][]
=
{{
""
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
},
// 00
{
""
,
"[1 1]"
,
"[2 1] |"
,
"[3 1]"
,
"[4 1]"
,
"[5 1] |"
,
"[6 1]"
,
"[7 1]"
,
"[8 1]"
,
"[9 1]"
},
// 01
{
""
,
"[1 2]"
,
"[2 2] |"
,
"[3 2]"
,
"[4 2]"
,
"[5 2] |"
,
"[6 2]"
,
"[7 2]"
,
"[8 2]"
,
"[9 2]"
},
// 02
{
""
,
"[1 3]"
,
"[2 3] |"
,
"[3 3]"
,
"[4 3]"
,
"[5 3] |"
,
"[6 3]"
,
"[7 3]"
,
"[8 3]"
,
"[9 3]"
},
// 03
{
""
,
"[1 4]"
,
"[2 9] |"
,
"[3 4]"
,
"[4 4]"
,
"[5 4] |"
,
"[6 4]"
,
"[7 4]"
,
"[8 4]"
,
"[9 4]"
},
// 04
{
""
,
"[1 5]"
,
"[2 8] |"
,
"[3 5]"
,
"[4 5]"
,
"[5 5] |"
,
"[6 5]"
,
"[7 5]"
,
"[8 5]"
,
"[9 5]"
},
// 05
{
""
,
"[1 6]"
,
"[2 7] |"
,
"[3 6]"
,
"[4 6]"
,
"[5 6] |"
,
"[6 6]"
,
"[7 6]"
,
"[8 6]"
,
"[9 6]"
},
// 06
{
""
,
"[1 7]"
,
"[2 6] |"
,
"[3 7]"
,
"[4 7]"
,
"[5 7] |"
,
"[6 7]"
,
"[7 7]"
,
"[8 7]"
,
"[9 7]"
},
// 07
{
""
,
"[1 8]"
,
"[2 5] |"
,
"[3 8]"
,
"[4 8]"
,
"[5 8] |"
,
"[6 8]"
,
"[7 8]"
,
"[8 8]"
,
"[9 8]"
},
//08
{
""
,
"[1 9]"
,
"[2 4] |"
,
"[3 9]"
,
"[4 9]"
,
"[5 9] |"
,
"[6 9]"
,
"[7 9]"
,
"[8 9]"
,
"[9 9]"
}};
//09
out
.
println
(
"--First----|---Business-----|-----Economy--------"
);
display
(
board
);
out
.
println
(
""
);
out
.
println
(
"Enter > "
);
String
seatBook
=
input
.
next
();
// This allow store this specific string/data temp until the program crash
out
.
println
();
out
.
println
();
boardseatBook
.
add
(
seatBook
);
// make it easier for boarding class.
x
=
input
.
nextInt
();
y
=
input
.
nextInt
();
board
[
x
][
y
]
=
"[X X]"
;
while
(
true
)
{
if
(
board
[
x
][
y
]
==
"[X X]"
)
{
// if user type 0 3 it will break ????
break
;
}
}
System
.
out
.
print
(
"Seat: "
+
seatBook
);
out
.
println
();
out
.
println
(
"--First----|---Business-----|-----Economy--------"
);
display
(
board
);
out
.
println
();
out
.
println
(
"--------------------------------------------------------"
);
out
.
println
(
"Detail Check:"
);
out
.
println
(
"--------------------------------------------------------"
);
out
.
println
();
out
.
println
(
"Name--|--Last--|--Ori--|--Dest--|--Seat Num--"
);
int
size
=
boardName
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
out
.
println
(
boardName
.
get
(
i
)
+
"\t"
+
boardLast
.
get
(
i
)
+
"\t"
+
boardOrigins
.
get
(
i
)
+
"\t"
+
boardDestination
.
get
(
i
)
+
"\t"
+
boardseatBook
.
get
(
i
));
out
.
println
(
"--------------------------------"
);
}
}
// End documentSwitch > Line 130
public
static
void
display
(
String
board
[][])
{
// Displays board
for
(
int
i
=
1
;
i
<
10
;
i
++)
{
// Columns
for
(
int
j
=
1
;
j
<
10
;
j
++)
{
// Rows
System
.
out
.
print
(
board
[
i
][
j
]
+
""
);
}
System
.
out
.
println
();
}
}
// End display > Line 226
public
static
boolean
bookedSeats
(
String
a
,
String
board
[][])
{
// Conditions if first class is fully booked...
if
(
a
.
equals
((
board
[
1
][
1
]
+
board
[
1
][
2
]
+
board
[
1
][
3
]
+
board
[
1
][
4
]
+
board
[
1
][
5
]
+
board
[
1
][
6
]
+
board
[
1
][
7
]
+
board
[
1
][
8
]
+
board
[
1
][
9
]
))
||
a
.
equals
((
board
[
2
][
1
]
+
board
[
2
][
2
]
+
board
[
2
][
3
]
+
board
[
2
][
4
]
+
board
[
2
][
5
]
+
board
[
2
][
6
]
+
board
[
2
][
7
]
+
board
[
2
][
8
]
+
board
[
2
][
9
]
))
||
a
.
equals
((
board
[
3
][
1
]
+
board
[
3
][
2
]
+
board
[
3
][
3
]
+
board
[
3
][
4
]
+
board
[
3
][
5
]
+
board
[
3
][
6
]
+
board
[
3
][
7
]
+
board
[
3
][
8
]
+
board
[
3
][
9
]
))
||
a
.
equals
((
board
[
4
][
1
]
+
board
[
4
][
2
]
+
board
[
4
][
3
]
+
board
[
4
][
4
]
+
board
[
4
][
5
]
+
board
[
4
][
6
]
+
board
[
4
][
7
]
+
board
[
4
][
8
]
+
board
[
4
][
9
]
))
||
a
.
equals
((
board
[
5
][
1
]
+
board
[
5
][
2
]
+
board
[
5
][
3
]
+
board
[
5
][
4
]
+
board
[
5
][
5
]
+
board
[
5
][
6
]
+
board
[
5
][
7
]
+
board
[
5
][
8
]
+
board
[
5
][
9
]
))
||
a
.
equals
((
board
[
6
][
1
]
+
board
[
6
][
2
]
+
board
[
6
][
3
]
+
board
[
6
][
4
]
+
board
[
6
][
5
]
+
board
[
6
][
6
]
+
board
[
6
][
7
]
+
board
[
6
][
8
]
+
board
[
6
][
9
]
))
||
a
.
equals
((
board
[
7
][
1
]
+
board
[
7
][
2
]
+
board
[
7
][
3
]
+
board
[
7
][
4
]
+
board
[
7
][
5
]
+
board
[
7
][
6
]
+
board
[
7
][
7
]
+
board
[
7
][
8
]
+
board
[
7
][
9
]
))
||
a
.
equals
((
board
[
8
][
1
]
+
board
[
8
][
2
]
+
board
[
8
][
3
]
+
board
[
8
][
4
]
+
board
[
8
][
5
]
+
board
[
8
][
6
]
+
board
[
8
][
7
]
+
board
[
8
][
8
]
+
board
[
8
][
9
]
))
||
a
.
equals
((
board
[
9
][
1
]
+
board
[
9
][
2
]
+
board
[
9
][
3
]
+
board
[
9
][
4
]
+
board
[
9
][
5
]
+
board
[
9
][
6
]
+
board
[
9
][
7
]
+
board
[
9
][
8
]
+
board
[
9
][
9
]
)))
return
true
;
else
return
false
;
}
// end for firstClass boolean > Line 236
private
static
void
boardingSwitch
()
{
out
.
println
(
"Name--|--Last--|--Ori--|--Dest--|--Seat Num--"
);
int
size
=
boardName
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
out
.
println
(
boardName
.
get
(
i
)
+
"\t"
+
boardLast
.
get
(
i
)
+
"\t"
+
boardOrigins
.
get
(
i
)
+
"\t"
+
boardDestination
.
get
(
i
)
+
"\t"
+
boardseatBook
.
get
(
i
));
out
.
println
(
"--------------------------------"
);
}
}
private
static
void
managementRole
()
{
out
.
println
(
"Name--|--Last--|--Ori--|--Dest--|--Seat Num--"
);
int
size
=
boardName
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
out
.
println
(
boardName
.
get
(
i
)
+
"\t"
+
boardLast
.
get
(
i
)
+
"\t"
+
boardOrigins
.
get
(
i
)
+
"\t"
+
boardDestination
.
get
(
i
)
+
"\t"
+
boardseatBook
.
get
(
i
));
out
.
println
(
"--------------------------------"
);
}
}
// end managementRoles
// Copy & Paste & other stuff NOT RELEVENT
// I thought this how the string board WOULD OF WORK lol...
//String board[][] = {{"", " ", " ", " ", " ", " ", " ", " ", " ", " "}, // 00
//{"", "[01]", "[02]", "[0 3]", "[0 4]", "[0 5]", "[0 6]", "[0 7]", "[0 8]", "[0 9]"}, // 01
//{"", "[10]", "[1 1]", "[1 2]", "[1 3]", "[1 4]", "[1 5]", "[1 6]", "[1 7]", "[1 8]"}, // 02
//{"", "[1 9]", "[2 0]", "[2 1]", "[2 2]", "[2 1]", "[2 2]", "[2 3]", "[2 4]", "[2 5]"},
//{"", "[2 8]", "[2 9]", "[3 0]", "[3 1]", "[3 2]", "[3 3]", "[3 4]", "[3 5]", "[3 6]"},
//{"", "[3 7]", "[3 8]", "[3 9]", "[4 0]", "[4 1]", "[4 2]", "[4 3]", "[4 4]", "[4 5]"},
//{"", "[4 6]", "[4 7]", "[4 8]", "[4 9]", "[5 0]", "[5 1]", "[5 2]", "[5 3]", "[5 4]"},
//{"", "[5 5]", "[5 6]", "[5 7]", "[5 8]", "[5 9]", "[6 0]", "[6 1]", "[6 2]", "[5 3]"},
//{"", "[6 4]", "[6 5]", "[6 6]", "[6 7]", "[6 8]", "[6 9]", "[7 0]", "[7 1]", "[7 2]"},
//{"", "[7 3]", "[7 4]", "[7 5]", "[7 6]", "[7 7]", "[7 8]", "[7 9]", "[8 0]", "[8 1]"},
//{"", "[8 2]", "[8 3]", "[8 4]", "[8 5]", "[8 6]", "[8 7]", "[8 8]", "[8 9]", "[9 0]"}};
//String board[][] = {{"", "", "", "", "", "", "", "", "", ""}, // 00
//{"", "", "", "", "", "", "", "", "", ""}, // 01
//{"", "", "", "", "", "", "", "", "", ""}, // 02
//{"", "", "", "", "", "", "", "", "", ""},
//{"", "", "", "", "", "", "", "", "", ""},
//{"", "", "", "", "", "", "", "", "", ""},
//{"", "", "", "", "", "", "", "", "", ""},
//{"", "", "", "", "", "", "", "", "", ""},
//{"", "", "", "", "", "", "", "", "", ""},
//{"", "", "", "", "", "", "", "", "", ""},
//{"", "", "", "", "", "", "", "", "", ""}};
// BELOW IS MY INTENTIONS ON HOW I WOULD LIKE TO DO MY STRING BOARD OKAY
// I thought this how the matrix works but NOPE.
// Java: Thats not how the force works!
//out.println(" First Class \n"
//+ "[01] [02] [03] | [04] [05] [06] | [07] [08] [09]\n"
//+ "[10] [11] [12] | [13] [14] [15] | [16] [17] [18]\n"
//+ "------------------------------------------------\n"
//+ " Business Class \n"
//+ "------------------------------------------------\n"
//+ "[01] [02] [03] | [04] [05] [06] | [07] [08] [09]\n"
//+ "[10] [11] [12] | [13] [14] [15] | [16] [17] [18]\n"
//+ "[19] [20] [21] | [22] [24] [25] | [26] [27] [28]\n"
//+ "------------------------------------------------\n"
//+ " Economy Class \n"
//+ "------------------------------------------------\n"
//+ "[01] [02] [03] | [04] [05] [06] | [07] [08] [09]\n"
//+ "[10] [11] [12] | [13] [14] [15] | [16] [17] [18]\n"
//+ "[19] [20] [21] | [22] [24] [25] | [26] [27] [28]\n"
//+ "[29] [30] [31] | [32] [33] [34] | [35] [36] [37]\n"
//+ "[38] [39] [40] | [41] [42] [43] | [44] [45] [46]\n");
}
// End Class
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment