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
ff5b6713
Commit
ff5b6713
authored
Nov 04, 2019
by
charlie.hamer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished
parent
e9b7b80c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
38 deletions
+49
-38
airline.java
AirlineReservation/src/airline.java
+49
-38
No files found.
AirlineReservation/src/airline.java
View file @
ff5b6713
import
java.util.Scanner
;
//import scanner
import
java.util.Random
;
//I don't know the requirements for generating a flight code, so I will generate one randomly
import
java.util.Arrays
;
import
java.util.List
;
public
class
airline
{
static
String
plane
[][]
=
{{
"01"
,
"02"
,
"03"
},
{
"04"
,
"05"
,
"06"
},
{
"07"
,
"08"
,
"09"
},
// set plane as global variable
{
"10"
,
"11"
,
"12"
},
{
"13"
,
"14"
,
"15"
},
{
"16"
,
"17"
,
"18"
},
...
...
@@ -22,7 +24,6 @@ public class airline {
static
Random
random
=
new
Random
();
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
print
(
plane
[
0
][
0
]);
details
();
//to allow repeatability at the end of the program
}
...
...
@@ -72,9 +73,9 @@ public class airline {
boolean
available
=
false
;
System
.
out
.
println
(
"You have chosen First Class"
);
//confirms class
for
(
int
i
=
0
;
i
<
1
;
i
++)
{
for
(
int
i
=
0
;
i
<
6
;
i
++)
{
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
if
(
plane
[
i
][
j
]
!=
"XX"
)
{
if
(
!
plane
[
i
][
j
].
contentEquals
(
"XX"
)
)
{
available
=
true
;
//checking if seats are available
}
else
...
...
@@ -107,9 +108,9 @@ public class airline {
boolean
available
=
false
;
System
.
out
.
println
(
"You have chosen Business"
);
//confirms class
for
(
int
i
=
2
;
i
<
4
;
i
++)
{
for
(
int
i
=
6
;
i
<
15
;
i
++)
{
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
if
(
plane
[
i
][
j
]
!=
"XX"
)
{
if
(
!
plane
[
i
][
j
].
contentEquals
(
"XX"
)
)
{
available
=
true
;
//checking if seats are available
}
else
...
...
@@ -145,9 +146,9 @@ public class airline {
boolean
available
=
false
;
System
.
out
.
println
(
"You have chosen Economy"
);
//confirms class
for
(
int
i
=
5
;
i
<
9
;
i
++)
{
for
(
int
i
=
15
;
i
<
30
;
i
++)
{
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
if
(
plane
[
i
][
j
]
!=
"XX"
)
{
if
(
!
plane
[
i
][
j
].
contentEquals
(
"XX"
)
)
{
available
=
true
;
//checking if seats are available
}
else
...
...
@@ -201,7 +202,7 @@ public class airline {
case
"First Class"
:
for
(
int
i
=
0
;
i
<
1
;
i
++)
{
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
if
(
plane
[
i
][
j
]
!=
"XX"
)
{
//checks through seats, finds one that hasn't been filled yet
if
(
!
seat
.
contentEquals
(
plane
[
i
][
j
]))
{
//checks through seats, finds one that hasn't been filled yet
seat
=
plane
[
i
][
j
];
plane
[
i
][
j
]
=
"XX"
;
break
;
...
...
@@ -211,7 +212,7 @@ public class airline {
case
"Business"
:
for
(
int
i
=
2
;
i
<
4
;
i
++)
{
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
if
(
plane
[
i
][
j
]
!=
"XX"
)
{
//checks through seats, finds one that hasn't been filled yet
if
(
!
seat
.
contentEquals
(
plane
[
i
][
j
]))
{
//checks through seats, finds one that hasn't been filled yet
seat
=
plane
[
i
][
j
];
plane
[
i
][
j
]
=
"XX"
;
break
;
...
...
@@ -221,7 +222,7 @@ public class airline {
case
"Economy"
:
for
(
int
i
=
5
;
i
<
9
;
i
++)
{
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
if
(
plane
[
i
][
j
]
!=
"XX"
)
{
//checks through seats, finds one that hasn't been filled yet
if
(!
seat
.
contentEquals
(
plane
[
i
][
j
]))
{
//checks through seats, finds one that hasn't been filled yet
seat
=
plane
[
i
][
j
];
plane
[
i
][
j
]
=
"XX"
;
break
;
...
...
@@ -242,44 +243,54 @@ public class airline {
switch
(
fclass
)
{
case
"First Class"
:
seat
=
input
.
next
();
if
(
Integer
.
parseInt
(
seat
)
>
18
)
{
//making sure the seat they choose is in their chosen class
chooseseat
(
fclass
);
}
for
(
int
i
=
0
;
i
<
6
;
i
++)
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
System
.
out
.
println
(
plane
[
i
][
j
]);
if
(
seat
==
plane
[
i
][
j
])
if
(
seat
.
contentEquals
(
plane
[
i
][
j
]))
{
plane
[
i
][
j
]
=
"XX"
;
}
if
(
Integer
.
parseInt
(
seat
)
>
18
)
{
//making sure the seat they choose is in their chosen class
chooseseat
(
fclass
);
}
boardingpass
(
fclass
);
//loads up the boarding class
}
}
System
.
out
.
println
(
"Sorry, that seat is taken"
);
chooseseat
(
fclass
);
break
;
case
"Business"
:
seat
=
input
.
next
();
for
(
int
i
=
6
;
i
<
15
;
i
++)
{
for
(
int
i
=
6
;
i
<
15
;
i
++)
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
if
(
seat
==
plane
[
i
][
j
])
if
(
seat
.
contentEquals
(
plane
[
i
][
j
]))
{
plane
[
i
][
j
]
=
"XX"
;
}
if
(
Integer
.
parseInt
(
seat
)
<
18
)
{
//making sure the seat they choose is in their chosen class
chooseseat
(
fclass
);}
if
(
Integer
.
parseInt
(
seat
)
>
45
)
{
chooseseat
(
fclass
);}
boardingpass
(
fclass
);
//loads up the boarding class
}
if
(
plane
[
i
][
j
].
contentEquals
(
"XX"
)){
System
.
out
.
println
(
"Sorry, that seat is taken"
);
chooseseat
(
fclass
);}
}
break
;
case
"Economy"
:
seat
=
input
.
next
();
for
(
int
i
=
15
;
i
<
30
;
i
++)
{
for
(
int
i
=
15
;
i
<
30
;
i
++)
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
if
(
seat
==
plane
[
i
][
j
])
if
(
seat
.
contentEquals
(
plane
[
i
][
j
]))
{
plane
[
i
][
j
]
=
"XX"
;
if
(
Integer
.
parseInt
(
seat
)
<
46
)
{
//making sure the seat they choose is in their chosen class
chooseseat
(
fclass
);
}
boardingpass
(
fclass
);
//loads up the boarding class
}
if
(
Integer
.
parseInt
(
seat
)
<
45
)
{
//making sure the seat they choose is in their chosen class
if
(
plane
[
i
][
j
].
contentEquals
(
"XX"
)){
System
.
out
.
println
(
"Sorry, that seat is taken"
);
chooseseat
(
fclass
);}
boardingpass
(
fclass
);
//loads up the boarding class
break
;
}
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