Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Airline Reservation
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
charlie.hamer
Airline Reservation
Commits
b27a86ec
Commit
b27a86ec
authored
Nov 04, 2019
by
charlie.hamer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes to assigning seat + comments23
parent
fd747a5a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
17 deletions
+20
-17
airline.java
AirlineReservation/src/airline.java
+20
-17
No files found.
AirlineReservation/src/airline.java
View file @
b27a86ec
...
@@ -27,11 +27,11 @@ public class airline {
...
@@ -27,11 +27,11 @@ public class airline {
public
static
void
details
()
{
public
static
void
details
()
{
System
.
out
.
print
(
"What is your name?"
);
System
.
out
.
print
(
"What is your name?
"
);
name
=
input
.
next
();
name
=
input
.
next
();
System
.
out
.
print
(
"Where will you be flying from?"
);
System
.
out
.
print
(
"Where will you be flying from?
"
);
ocity
=
input
.
next
();
ocity
=
input
.
next
();
System
.
out
.
print
(
"Where are you flying to?"
);
System
.
out
.
print
(
"Where are you flying to?
"
);
dcity
=
input
.
next
();
// getting customer details
dcity
=
input
.
next
();
// getting customer details
Class
();
Class
();
...
@@ -44,8 +44,8 @@ public class airline {
...
@@ -44,8 +44,8 @@ public class airline {
System
.
out
.
print
(
"Choose a flight class-"
System
.
out
.
print
(
"Choose a flight class-"
+
"\nPlease type 1 for First Class"
+
"\nPlease type 1 for First Class
"
+
"\nPlease type 2 for Business"
+
"\nPlease type 2 for Business
"
+
"\nPlease type 3 for Economy \n"
);
+
"\nPlease type 3 for Economy \n"
);
while
(
true
){
while
(
true
){
switch
(
fclass
=
input
.
next
())
{
switch
(
fclass
=
input
.
next
())
{
...
@@ -59,7 +59,7 @@ public class airline {
...
@@ -59,7 +59,7 @@ public class airline {
economy
();
economy
();
break
;
break
;
default
:
//case if user chooses an invalid option
default
:
//case if user chooses an invalid option
System
.
out
.
println
(
"Invalid option. Please choose a number from 1 to 3"
);
//prints out an error message
System
.
out
.
println
(
"Invalid option. Please choose a number from 1 to 3
"
);
//prints out an error message
break
;
break
;
}}
}}
}
}
...
@@ -80,7 +80,7 @@ public class airline {
...
@@ -80,7 +80,7 @@ public class airline {
}
}
}
}
if
(
available
==
true
)
{
//if seats are available
if
(
available
==
true
)
{
//if seats are available
System
.
out
.
println
(
"Would you like to choose a seat?(y/n)"
);
System
.
out
.
println
(
"Would you like to choose a seat?(y/n)
"
);
while
(
true
)
{
while
(
true
)
{
String
chooseseat
=
input
.
next
();
String
chooseseat
=
input
.
next
();
switch
(
chooseseat
)
{
switch
(
chooseseat
)
{
...
@@ -117,7 +117,7 @@ public class airline {
...
@@ -117,7 +117,7 @@ public class airline {
}
}
if
(
available
==
true
)
{
//if seats are available
if
(
available
==
true
)
{
//if seats are available
System
.
out
.
println
(
"Would you like to choose a seat?(y/n)"
);
System
.
out
.
println
(
"Would you like to choose a seat?(y/n)
"
);
String
chooseseat
=
input
.
next
();
String
chooseseat
=
input
.
next
();
switch
(
chooseseat
)
{
switch
(
chooseseat
)
{
case
"n"
:
case
"n"
:
...
@@ -154,7 +154,7 @@ public class airline {
...
@@ -154,7 +154,7 @@ public class airline {
}
}
}
}
if
(
available
==
true
)
{
//if seats are available
if
(
available
==
true
)
{
//if seats are available
System
.
out
.
println
(
"Would you like to choose a seat?(y/n)"
);
System
.
out
.
println
(
"Would you like to choose a seat?(y/n)
"
);
String
chooseseat
=
input
.
next
();
String
chooseseat
=
input
.
next
();
switch
(
chooseseat
)
{
switch
(
chooseseat
)
{
case
"n"
:
case
"n"
:
...
@@ -198,37 +198,39 @@ public class airline {
...
@@ -198,37 +198,39 @@ public class airline {
private
static
void
assign
(
String
fclass
)
{
private
static
void
assign
(
String
fclass
)
{
switch
(
fclass
)
{
switch
(
fclass
)
{
case
"First Class"
:
case
"First Class"
:
for
(
int
i
=
0
;
i
<
1
;
i
++)
{
for
(
int
i
=
0
;
i
<
6
;
i
++)
{
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
if
(!
seat
.
contentEquals
(
plane
[
i
][
j
]
))
{
//checks through seats, finds one that hasn't been filled yet
if
(!
plane
[
i
][
j
].
contentEquals
(
"XX"
))
{
//checks through seats, finds one that hasn't been filled yet
seat
=
plane
[
i
][
j
];
seat
=
plane
[
i
][
j
];
plane
[
i
][
j
]
=
"XX"
;
plane
[
i
][
j
]
=
"XX"
;
boardingpass
(
fclass
);
//loads up the boarding class
break
;
break
;
}
}
}
}
}
}
case
"Business"
:
case
"Business"
:
for
(
int
i
=
2
;
i
<
4
;
i
++)
{
for
(
int
i
=
6
;
i
<
15
;
i
++)
{
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
if
(!
seat
.
contentEquals
(
plane
[
i
][
j
]
))
{
//checks through seats, finds one that hasn't been filled yet
if
(!
plane
[
i
][
j
].
contentEquals
(
"XX"
))
{
//checks through seats, finds one that hasn't been filled yet
seat
=
plane
[
i
][
j
];
seat
=
plane
[
i
][
j
];
plane
[
i
][
j
]
=
"XX"
;
plane
[
i
][
j
]
=
"XX"
;
boardingpass
(
fclass
);
//loads up the boarding class
break
;
break
;
}
}
}
}
}
}
case
"Economy"
:
case
"Economy"
:
for
(
int
i
=
5
;
i
<
9
;
i
++)
{
for
(
int
i
=
15
;
i
<
30
;
i
++)
{
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
if
(!
seat
.
contentEquals
(
plane
[
i
][
j
]
))
{
//checks through seats, finds one that hasn't been filled yet
if
(!
plane
[
i
][
j
].
contentEquals
(
"XX"
))
{
//checks through seats, finds one that hasn't been filled yet
seat
=
plane
[
i
][
j
];
seat
=
plane
[
i
][
j
];
plane
[
i
][
j
]
=
"XX"
;
plane
[
i
][
j
]
=
"XX"
;
boardingpass
(
fclass
);
//loads up the boarding class
break
;
break
;
}
}
}
}
}
}
}
}
boardingpass
(
fclass
);
//loads up the boarding class
}
}
public
static
void
chooseseat
(
String
fclass
)
{
public
static
void
chooseseat
(
String
fclass
)
{
...
@@ -307,7 +309,8 @@ public class airline {
...
@@ -307,7 +309,8 @@ public class airline {
System
.
out
.
println
(
"To : "
+
dcity
);
System
.
out
.
println
(
"To : "
+
dcity
);
System
.
out
.
println
(
"Flight : FL"
+
flight
[
select
]);
System
.
out
.
println
(
"Flight : FL"
+
flight
[
select
]);
System
.
out
.
println
(
"Seat No. : "
+
seat
);
System
.
out
.
println
(
"Seat No. : "
+
seat
);
System
.
out
.
println
(
"Section : "
+
fclass
);
System
.
out
.
println
(
"Section : "
+
fclass
);
//when testing, scroll up to see whole boarding pass
System
.
out
.
println
(
""
);
display
();
display
();
System
.
out
.
println
(
""
);
System
.
out
.
println
(
""
);
System
.
out
.
println
(
"Would you like to book another?"
);
//the choice to restart the program essentially
System
.
out
.
println
(
"Would you like to book another?"
);
//the choice to restart the program essentially
...
...
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