Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AirlineReservation
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
hayden.gooi
AirlineReservation
Commits
843a989a
Commit
843a989a
authored
Nov 03, 2019
by
User
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes
parent
a96f5caf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
10 deletions
+24
-10
reservation.java
src/airlinereservation/reservation.java
+24
-10
No files found.
src/airlinereservation/reservation.java
View file @
843a989a
...
...
@@ -6,16 +6,26 @@ public class reservation {
Scanner
input
=
new
Scanner
(
System
.
in
);
int
choice
=
0
;
String
reserve
=
""
;
String
plane
[][]
=
{{
"XX"
,
"XX"
,
"XX"
},
{
"
04"
,
"05
"
,
"06"
},
{
"07"
,
"08"
,
"09"
},
//initialise the array which contains the plane seats
String
plane
[][]
=
{{
"XX"
,
"XX"
,
"XX"
},
{
"
XX"
,
"XX
"
,
"06"
},
{
"07"
,
"08"
,
"09"
},
//initialise the array which contains the plane seats
{
"10"
,
"11"
,
"12"
},
{
"13"
,
"14"
,
"15"
},
{
"16"
,
"17"
,
"18"
},
{
"
19"
,
"20"
,
"21"
},
{
"22"
,
"23"
,
"24"
},
{
"25"
,
"26"
,
"27
"
},
{
"
XX"
,
"XX"
,
"XX"
},
{
"XX"
,
"XX"
,
"XX"
},
{
"XX"
,
"XX"
,
"XX
"
},
{
"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
"
},
//listing of all seat numbers
{
"
55"
,
"56"
,
"57"
},
{
"58"
,
"59"
,
"60"
},
{
"61"
,
"62"
,
"63
"
},
{
"
64"
,
"65"
,
"66"
},
{
"67"
,
"68"
,
"69"
},
{
"70
"
,
"71"
,
"72"
},
{
"
XX"
,
"XX"
,
"XX"
},
{
"XX"
,
"XX"
,
"XX"
},
{
"XX"
,
"XX"
,
"XX
"
},
//listing of all seat numbers
{
"
XX"
,
"XX"
,
"XX"
},
{
"XX"
,
"XX"
,
"XX"
},
{
"XX"
,
"XX"
,
"XX
"
},
{
"
XX"
,
"XX"
,
"XX"
},
{
"XX"
,
"XX"
,
"XX"
},
{
"XX
"
,
"71"
,
"72"
},
{
"73"
,
"74"
,
"75"
},
{
"76"
,
"77"
,
"78"
},
{
"79"
,
"80"
,
"81"
},
{
"82"
,
"83"
,
"84"
},
{
"85"
,
"86"
,
"87"
},
{
"88"
,
"89"
,
"90"
}};
String
first
=
""
,
last
=
""
,
city
=
""
,
destination
=
""
;
System
.
out
.
println
(
"Hello and Welcome. We first need some details-"
);
System
.
out
.
print
(
"Please enter your first name: "
);
first
=
input
.
next
();
System
.
out
.
print
(
"Please enter your last name: "
);
last
=
input
.
next
();
System
.
out
.
print
(
"Please enter your origin city: "
);
city
=
input
.
next
();
System
.
out
.
print
(
"Please enter your flight destination: "
);
destination
=
input
.
next
();
while
(
true
)
{
//loop to repeat code
System
.
out
.
print
(
"Choose a flight Class-"
//print out options to the user
+
"\nPlease Type 1 for First Class"
...
...
@@ -25,7 +35,7 @@ public class reservation {
case
1
:
//case if user chooses first class/1
System
.
out
.
println
(
"You have Chosen First Class"
);
//prints out the class that the user has chosen
boolean
seat
=
false
;
for
(
int
p
=
0
;
p
<
1
;
p
++)
{
for
(
int
p
=
0
;
p
<
6
;
p
++)
{
for
(
int
q
=
0
;
q
<
3
;
q
++)
{
if
(
plane
[
p
][
q
]
!=
"XX"
)
{
seat
=
true
;
...
...
@@ -39,7 +49,7 @@ public class reservation {
switch
(
choose
)
{
case
"N"
:
System
.
out
.
println
(
"Ok, You will be assigned the next available seat"
);
for
(
int
s
=
0
;
s
<
1
;
s
++)
{
for
(
int
s
=
0
;
s
<
6
;
s
++)
{
for
(
int
r
=
0
;
r
<
3
;
r
++)
{
if
(
plane
[
s
][
r
]
!=
"XX"
)
{
reserve
=
plane
[
s
][
r
];
...
...
@@ -57,7 +67,11 @@ public class reservation {
display
(
plane
);
System
.
out
.
println
(
"\nSeat choice: "
);
reserve
=
input
.
next
();
for
(
int
s
=
0
;
s
<
1
;
s
++)
{
if
(
reserve
.
equals
(
"XX"
))
{
System
.
out
.
println
(
"Input cannot be XX"
);
continue
;
}
for
(
int
s
=
0
;
s
<
6
;
s
++)
{
for
(
int
r
=
0
;
r
<
3
;
r
++)
{
if
(
reserve
.
equals
(
plane
[
s
][
r
]))
{
System
.
out
.
println
(
"Seat "
+
reserve
+
" has been booked for you"
);
...
...
@@ -66,9 +80,9 @@ public class reservation {
return
;
}
}
System
.
out
.
println
(
"Invalid input. Please choose an available seat. Seats with XX have been booked already and are not available"
);
return
;
}
System
.
out
.
println
(
"Invalid input. Please choose an available seat. Seats with XX have been booked already and are not available"
);
break
;
default
:
System
.
out
.
println
(
"invalid input please choose Y or N"
);
break
;
...
...
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