Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Airline Reservation Final
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
Airline Reservation Final
Commits
cdc4e595
Commit
cdc4e595
authored
Nov 04, 2019
by
hayden.gooi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parents
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
269 additions
and
0 deletions
+269
-0
.classpath
.classpath
+6
-0
.gitignore
.gitignore
+1
-0
.project
.project
+17
-0
org.eclipse.jdt.core.prefs
.settings/org.eclipse.jdt.core.prefs
+11
-0
reservation.java
src/ar/reservation.java
+234
-0
No files found.
.classpath
0 → 100644
View file @
cdc4e595
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"
/>
<classpathentry
kind=
"src"
path=
"src"
/>
<classpathentry
kind=
"output"
path=
"bin"
/>
</classpath>
.gitignore
0 → 100644
View file @
cdc4e595
/bin/
.project
0 → 100644
View file @
cdc4e595
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>
ar
</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>
org.eclipse.jdt.core.javabuilder
</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>
org.eclipse.jdt.core.javanature
</nature>
</natures>
</projectDescription>
.settings/org.eclipse.jdt.core.prefs
0 → 100644
View file @
cdc4e595
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
src/ar/reservation.java
0 → 100644
View file @
cdc4e595
package
ar
;
import
java.util.Scanner
;
public
class
reservation
{
public
static
String
plane
[][]
=
{{
"XX"
,
"XX"
,
"XX"
},
{
"XX"
,
"XX"
,
"06"
},
{
"07"
,
"08"
,
"09"
},
//Initialize the array which contains the plane seats
{
"10"
,
"11"
,
"12"
},
{
"13"
,
"14"
,
"15"
},
{
"16"
,
"17"
,
"18"
},
{
"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"
},
{
"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"
}};
public
static
void
main
(
String
[]
args
)
{
//main subprogram
Scanner
input
=
new
Scanner
(
System
.
in
);
int
choice
=
0
;
String
reserve
=
""
,
section
=
""
;
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"
+
"\nPlease Type 2 for Business"
+
"\nPlease Type 3 for Economy \n"
);
switch
(
choice
=
input
.
nextInt
())
{
//switch case to run different outcomes
case
1
:
//case if user chooses first class/1
section
=
"First class"
;
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
<
6
;
p
++)
{
for
(
int
q
=
0
;
q
<
3
;
q
++)
{
if
(
plane
[
p
][
q
]
!=
"XX"
)
{
seat
=
true
;
}
}
}
if
(
seat
==
true
)
{
while
(
true
)
{
System
.
out
.
println
(
"Would you like to choose a seat?(Y/N)"
);
String
choose
=
input
.
next
();
switch
(
choose
)
{
case
"N"
:
System
.
out
.
println
(
"Ok, You will be assigned the next available seat"
);
for
(
int
s
=
0
;
s
<
6
;
s
++)
{
for
(
int
r
=
0
;
r
<
3
;
r
++)
{
if
(
plane
[
s
][
r
]
!=
"XX"
)
{
reserve
=
plane
[
s
][
r
];
plane
[
s
][
r
]
=
"XX"
;
System
.
out
.
println
(
"Your booked seat is "
+
reserve
);
ticket
(
first
,
last
,
city
,
destination
,
section
,
reserve
);
return
;
}
}
}
return
;
case
"Y"
:
System
.
out
.
println
(
"Ok please choose a seat:"
+
"\n Here is the plane seat layout"
);
display
(
plane
);
System
.
out
.
println
(
"\nSeat choice: "
);
reserve
=
input
.
next
();
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"
);
plane
[
s
][
r
]
=
"XX"
;
ticket
(
first
,
last
,
city
,
destination
,
section
,
reserve
);
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
;
}
}
}
else
{
while
(
true
){
System
.
out
.
println
(
"There are no more seats, is it ok to be moved to another class?(Y/N)"
);
String
choose
=
input
.
next
();
switch
(
choose
)
{
case
"N"
:
System
.
out
.
println
(
"Sorry there is no available seat at the moment. The next flight is in 6 hours"
);
return
;
case
"Y"
:
for
(
int
s
=
6
;
s
<
15
;
s
++)
{
for
(
int
r
=
0
;
r
<
3
;
r
++)
{
if
(
plane
[
s
][
r
]
!=
"XX"
)
{
reserve
=
plane
[
s
][
r
];
plane
[
s
][
r
]
=
"XX"
;
section
=
"Business"
;
System
.
out
.
println
(
"Your booked seat is "
+
reserve
);
ticket
(
first
,
last
,
city
,
destination
,
section
,
reserve
);
return
;
}
}
}
for
(
int
s
=
15
;
s
<
30
;
s
++)
{
for
(
int
r
=
0
;
r
<
3
;
r
++)
{
if
(
plane
[
s
][
r
]
!=
"XX"
)
{
reserve
=
plane
[
s
][
r
];
plane
[
s
][
r
]
=
"XX"
;
section
=
"Economy"
;
System
.
out
.
println
(
"Your booked seat is "
+
reserve
);
ticket
(
first
,
last
,
city
,
destination
,
section
,
reserve
);
return
;
}
}
}
System
.
out
.
println
(
"Sorry there is no available seat in any class at the moment. The next flight is in 6 hours"
);
return
;
default
:
System
.
out
.
println
(
"invalid input please choose Y or N"
);
break
;
}
}
}
case
2
:
//case if user chooses business class/2
System
.
out
.
println
(
"You have Chosen Business Class"
);
//prints out the class that the user has chosen
break
;
case
3
:
//case if user chooses economy class/3
System
.
out
.
println
(
"You have Chosen Economy Class"
);
//prints out the class that the user has chosen
break
;
default
:
//case if user chooses an invalid option
System
.
out
.
println
(
"Invalid option. Please choose a number from 1 to 3\n------------"
);
//prints out an error message
break
;
}
}
}
public
static
void
display
(
String
plane
[][])
{
//create method called "display"
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
//for loop to print out set of seats
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
//nested loop for each item within the 2D array
System
.
out
.
print
(
"["
+
plane
[
i
][
j
]
+
"]"
);
//print out each individual seat
}
System
.
out
.
print
(
"\t"
);
//print out spacing after 3 seats
}
System
.
out
.
println
();
//print new line
for
(
int
i
=
3
;
i
<
6
;
i
++)
{
//for loop to print out set of seats
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
//nested loop for each item within the 2D array
System
.
out
.
print
(
"["
+
plane
[
i
][
j
]
+
"]"
);
//print out each individual seat
}
System
.
out
.
print
(
"\t"
);
}
System
.
out
.
println
();
//print new line to separate class seats
System
.
out
.
println
();
for
(
int
i
=
6
;
i
<
9
;
i
++)
{
//for loop to print out set of seats
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
//nested loop for each item within the 2D array
System
.
out
.
print
(
"["
+
plane
[
i
][
j
]
+
"]"
);
//print out each individual seat
}
System
.
out
.
print
(
"\t"
);
}
System
.
out
.
println
();
for
(
int
i
=
9
;
i
<
12
;
i
++)
{
//for loop to print out set of seats
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
//nested loop for each item within the 2D array
System
.
out
.
print
(
"["
+
plane
[
i
][
j
]
+
"]"
);
//print out each individual seat
}
System
.
out
.
print
(
"\t"
);
}
System
.
out
.
println
();
for
(
int
i
=
12
;
i
<
15
;
i
++)
{
//for loop to print out set of seats
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
//nested loop for each item within the 2D array
System
.
out
.
print
(
"["
+
plane
[
i
][
j
]
+
"]"
);
//print out each individual seat
}
System
.
out
.
print
(
"\t"
);
}
System
.
out
.
println
();
//print new line to separate class seats
System
.
out
.
println
();
for
(
int
i
=
15
;
i
<
18
;
i
++)
{
//for loop to print out set of seats
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
//nested loop for each item within the 2D array
System
.
out
.
print
(
"["
+
plane
[
i
][
j
]
+
"]"
);
//print out each individual seat
}
System
.
out
.
print
(
"\t"
);
}
System
.
out
.
println
();
for
(
int
i
=
18
;
i
<
21
;
i
++)
{
//for loop to print out set of seats
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
//nested loop for each item within the 2D array
System
.
out
.
print
(
"["
+
plane
[
i
][
j
]
+
"]"
);
//print out each individual seat
}
System
.
out
.
print
(
"\t"
);
}
System
.
out
.
println
();
for
(
int
i
=
21
;
i
<
24
;
i
++)
{
//for loop to print out set of seats
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
//nested loop for each item within the 2D array
System
.
out
.
print
(
"["
+
plane
[
i
][
j
]
+
"]"
);
//print out each individual seat
}
System
.
out
.
print
(
"\t"
);
}
System
.
out
.
println
();
for
(
int
i
=
24
;
i
<
27
;
i
++)
{
//for loop to print out set of seats
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
//nested loop for each item within the 2D array
System
.
out
.
print
(
"["
+
plane
[
i
][
j
]
+
"]"
);
//print out each individual seat
}
System
.
out
.
print
(
"\t"
);
}
System
.
out
.
println
();
for
(
int
i
=
27
;
i
<
30
;
i
++)
{
//for loop to print out set of seats
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
//nested loop for each item within the 2D array
System
.
out
.
print
(
"["
+
plane
[
i
][
j
]
+
"]"
);
//print out each individual seat
}
System
.
out
.
print
(
"\t"
);
}
}
public
static
void
ticket
(
String
first
,
String
last
,
String
city
,
String
destination
,
String
section
,
String
reserve
)
{
System
.
out
.
println
(
"Here are your ticket details:"
+
"\n|{BOARDING PASS}|"
+
"\n Name: "
+
first
+
" "
+
last
+
"\n From: "
+
city
+
"\n To: "
+
destination
+
"\n Flight: "
+
"\n Seat No.: "
+
reserve
+
"\n Section: "
+
section
+
"\n--------------------------"
);
System
.
out
.
println
(
"Thanks for using our booking service"
);
display
(
plane
);
}
void
main
()
{
}
}
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