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
Hide 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.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.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
{
public
class
airline
{
static
String
plane
[][]
=
{{
"01"
,
"02"
,
"03"
},
{
"04"
,
"05"
,
"06"
},
{
"07"
,
"08"
,
"09"
},
// set plane as global variable
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"
},
{
"10"
,
"11"
,
"12"
},
{
"13"
,
"14"
,
"15"
},
{
"16"
,
"17"
,
"18"
},
...
@@ -22,7 +24,6 @@ public class airline {
...
@@ -22,7 +24,6 @@ public class airline {
static
Random
random
=
new
Random
();
static
Random
random
=
new
Random
();
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
print
(
plane
[
0
][
0
]);
details
();
//to allow repeatability at the end of the program
details
();
//to allow repeatability at the end of the program
}
}
...
@@ -72,9 +73,9 @@ public class airline {
...
@@ -72,9 +73,9 @@ public class airline {
boolean
available
=
false
;
boolean
available
=
false
;
System
.
out
.
println
(
"You have chosen First Class"
);
//confirms class
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
++)
{
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
available
=
true
;
//checking if seats are available
}
}
else
else
...
@@ -107,9 +108,9 @@ public class airline {
...
@@ -107,9 +108,9 @@ public class airline {
boolean
available
=
false
;
boolean
available
=
false
;
System
.
out
.
println
(
"You have chosen Business"
);
//confirms class
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
++)
{
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
available
=
true
;
//checking if seats are available
}
}
else
else
...
@@ -145,9 +146,9 @@ public class airline {
...
@@ -145,9 +146,9 @@ public class airline {
boolean
available
=
false
;
boolean
available
=
false
;
System
.
out
.
println
(
"You have chosen Economy"
);
//confirms class
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
++)
{
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
available
=
true
;
//checking if seats are available
}
}
else
else
...
@@ -201,7 +202,7 @@ public class airline {
...
@@ -201,7 +202,7 @@ public class airline {
case
"First Class"
:
case
"First Class"
:
for
(
int
i
=
0
;
i
<
1
;
i
++)
{
for
(
int
i
=
0
;
i
<
1
;
i
++)
{
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
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
];
seat
=
plane
[
i
][
j
];
plane
[
i
][
j
]
=
"XX"
;
plane
[
i
][
j
]
=
"XX"
;
break
;
break
;
...
@@ -211,7 +212,7 @@ public class airline {
...
@@ -211,7 +212,7 @@ public class airline {
case
"Business"
:
case
"Business"
:
for
(
int
i
=
2
;
i
<
4
;
i
++)
{
for
(
int
i
=
2
;
i
<
4
;
i
++)
{
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
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
];
seat
=
plane
[
i
][
j
];
plane
[
i
][
j
]
=
"XX"
;
plane
[
i
][
j
]
=
"XX"
;
break
;
break
;
...
@@ -221,7 +222,7 @@ public class airline {
...
@@ -221,7 +222,7 @@ public class airline {
case
"Economy"
:
case
"Economy"
:
for
(
int
i
=
5
;
i
<
9
;
i
++)
{
for
(
int
i
=
5
;
i
<
9
;
i
++)
{
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
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
];
seat
=
plane
[
i
][
j
];
plane
[
i
][
j
]
=
"XX"
;
plane
[
i
][
j
]
=
"XX"
;
break
;
break
;
...
@@ -242,44 +243,54 @@ public class airline {
...
@@ -242,44 +243,54 @@ public class airline {
switch
(
fclass
)
{
switch
(
fclass
)
{
case
"First Class"
:
case
"First Class"
:
seat
=
input
.
next
();
seat
=
input
.
next
();
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
])
plane
[
i
][
j
]
=
"XX"
;
}
if
(
Integer
.
parseInt
(
seat
)
>
18
)
{
//making sure the seat they choose is in their chosen class
if
(
Integer
.
parseInt
(
seat
)
>
18
)
{
//making sure the seat they choose is in their chosen class
chooseseat
(
fclass
);
}
chooseseat
(
fclass
);
}
boardingpass
(
fclass
);
//loads up the boarding class
for
(
int
i
=
0
;
i
<
6
;
i
++)
for
(
int
j
=
0
;
j
<
3
;
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
;
break
;
case
"Business"
:
case
"Business"
:
seat
=
input
.
next
();
seat
=
input
.
next
();
for
(
int
i
=
6
;
i
<
15
;
i
++)
{
for
(
int
i
=
6
;
i
<
15
;
i
++)
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
if
(
seat
==
plane
[
i
][
j
])
if
(
seat
.
contentEquals
(
plane
[
i
][
j
]))
{
plane
[
i
][
j
]
=
"XX"
;
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
);}
}
}
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
}
break
;
break
;
case
"Economy"
:
case
"Economy"
:
seat
=
input
.
next
();
seat
=
input
.
next
();
for
(
int
i
=
15
;
i
<
30
;
i
++)
{
for
(
int
i
=
15
;
i
<
30
;
i
++)
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
if
(
seat
==
plane
[
i
][
j
])
if
(
seat
.
contentEquals
(
plane
[
i
][
j
]))
{
plane
[
i
][
j
]
=
"XX"
;
plane
[
i
][
j
]
=
"XX"
;
if
(
Integer
.
parseInt
(
seat
)
<
46
)
{
//making sure the seat they choose is in their chosen class
}
chooseseat
(
fclass
);
}
if
(
Integer
.
parseInt
(
seat
)
<
45
)
{
//making sure the seat they choose is in their chosen class
boardingpass
(
fclass
);
//loads up the boarding class
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
;
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