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
6605f01f
Commit
6605f01f
authored
Nov 04, 2019
by
User
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comments and display adjustments
parent
a1b4ad97
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
23 deletions
+29
-23
reservation.java
src/ar/reservation.java
+29
-23
No files found.
src/ar/reservation.java
View file @
6605f01f
package
ar
;
package
ar
;
import
java.util.Scanner
;
import
java.util.Scanner
;
//import modules
import
java.util.Random
;
import
java.util.Random
;
public
class
reservation
{
public
class
reservation
{
public
static
String
plane
[][]
=
{{
"XX"
,
"XX"
,
"XX"
},
{
"XX"
,
"XX"
,
"06"
},
{
"07"
,
"08"
,
"09"
},
//Initialize the array which contains the plane seats
public
static
String
plane
[][]
=
{{
"XX"
,
"XX"
,
"XX"
},
{
"XX"
,
"XX"
,
"06"
},
{
"07"
,
"08"
,
"09"
},
//Initialize the array which contains the plane seats
...
@@ -12,21 +12,25 @@ public class reservation{
...
@@ -12,21 +12,25 @@ public class reservation{
{
"XX"
,
"XX"
,
"XX"
},
{
"XX"
,
"XX"
,
"XX"
},
{
"XX"
,
"71"
,
"72"
},
{
"XX"
,
"XX"
,
"XX"
},
{
"XX"
,
"XX"
,
"XX"
},
{
"XX"
,
"71"
,
"72"
},
{
"73"
,
"74"
,
"75"
},
{
"76"
,
"77"
,
"78"
},
{
"79"
,
"80"
,
"81"
},
{
"73"
,
"74"
,
"75"
},
{
"76"
,
"77"
,
"78"
},
{
"79"
,
"80"
,
"81"
},
{
"82"
,
"83"
,
"84"
},
{
"85"
,
"86"
,
"87"
},
{
"88"
,
"89"
,
"90"
}};
{
"82"
,
"83"
,
"84"
},
{
"85"
,
"86"
,
"87"
},
{
"88"
,
"89"
,
"90"
}};
static
Random
random
=
new
Random
();
public
static
int
randomflightnum
(
int
min
,
int
max
){
//declare flight number generator method
int
num
=
(
int
)(
Math
.
random
()*((
max
-
min
)+
1
))+
min
;
//generate random number
return
num
;
//return generated number
}
public
static
void
main
(
String
[]
args
)
{
//main subprogram
public
static
void
main
(
String
[]
args
)
{
//main subprogram
Scanner
input
=
new
Scanner
(
System
.
in
);
Scanner
input
=
new
Scanner
(
System
.
in
);
String
choice
=
""
;
String
choice
=
""
;
//Initialise variables
String
reserve
=
""
,
section
=
""
;
String
reserve
=
""
,
section
=
""
;
String
first
=
""
,
last
=
""
,
city
=
""
,
destination
=
""
;
String
first
=
""
,
last
=
""
,
city
=
""
,
destination
=
""
;
//variables for customer details
System
.
out
.
println
(
"Hello and Welcome. We first need some details-"
);
System
.
out
.
println
(
"Hello and Welcome. We first need some details-"
);
//print out welcome message
System
.
out
.
print
(
"Please enter your first name: "
);
System
.
out
.
print
(
"Please enter your first name: "
);
//print out customer detail headings which inform the user what to type in
first
=
input
.
next
();
first
=
input
.
next
();
//grabs input and assigns it to a variable to be held
System
.
out
.
print
(
"Please enter your last name: "
);
System
.
out
.
print
(
"Please enter your last name: "
);
//print out customer detail headings which inform the user what to type in
last
=
input
.
next
();
last
=
input
.
next
();
//grabs input and assigns it to a variable to be held
System
.
out
.
print
(
"Please enter your origin city: "
);
System
.
out
.
print
(
"Please enter your origin city: "
);
//print out customer detail headings which inform the user what to type in
city
=
input
.
next
();
city
=
input
.
next
();
//grabs input and assigns it to a variable to be held
System
.
out
.
print
(
"Please enter your flight destination: "
);
System
.
out
.
print
(
"Please enter your flight destination: "
);
destination
=
input
.
next
();
destination
=
input
.
next
();
//print out customer detail headings which inform the user what to type in
while
(
true
)
{
//loop to repeat code
while
(
true
)
{
//loop to repeat code
System
.
out
.
print
(
"Choose a flight Class-"
//print out options to the user
System
.
out
.
print
(
"Choose a flight Class-"
//print out options to the user
+
"\nPlease Type 1 for First Class"
+
"\nPlease Type 1 for First Class"
...
@@ -34,18 +38,18 @@ public class reservation{
...
@@ -34,18 +38,18 @@ public class reservation{
+
"\nPlease Type 3 for Economy \n"
);
+
"\nPlease Type 3 for Economy \n"
);
switch
(
choice
=
input
.
next
())
{
//switch case to run different outcomes
switch
(
choice
=
input
.
next
())
{
//switch case to run different outcomes
case
"1"
:
//case if user chooses first class/1
case
"1"
:
//case if user chooses first class/1
section
=
"First class"
;
section
=
"First class"
;
//assigns the chosen class to the variable to be used later on
System
.
out
.
println
(
"You have Chosen First Class"
);
//prints out the class that the user has chosen
System
.
out
.
println
(
"You have Chosen First Class"
);
//prints out the class that the user has chosen
boolean
seat
=
false
;
boolean
seat
=
false
;
//boolean to check for available seats. Assumed that there are none
for
(
int
p
=
0
;
p
<
6
;
p
++)
{
for
(
int
p
=
0
;
p
<
6
;
p
++)
{
//loop to go through seats in the first class rows
for
(
int
q
=
0
;
q
<
3
;
q
++)
{
for
(
int
q
=
0
;
q
<
3
;
q
++)
{
if
(
plane
[
p
][
q
]
!=
"XX"
)
{
if
(
plane
[
p
][
q
]
!=
"XX"
)
{
//checks if array value is NOT EQUAL to XX which means that there is a seat available
seat
=
true
;
seat
=
true
;
//value of the boolean is changed to signify presence of free seat
}
}
}
}
}
}
if
(
seat
==
true
)
{
if
(
seat
==
true
)
{
//if statement to run code if seat is available
while
(
true
)
{
while
(
true
)
{
//while loop to display options
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
choose
=
input
.
next
();
String
choose
=
input
.
next
();
switch
(
choose
)
{
switch
(
choose
)
{
...
@@ -219,16 +223,18 @@ public class reservation{
...
@@ -219,16 +223,18 @@ public class reservation{
}
}
}
}
public
static
void
ticket
(
String
first
,
String
last
,
String
city
,
String
destination
,
String
section
,
String
reserve
)
{
public
static
void
ticket
(
String
first
,
String
last
,
String
city
,
String
destination
,
String
section
,
String
reserve
)
{
System
.
out
.
println
(
"Here are your ticket details:"
System
.
out
.
println
(
"Here are your ticket details:\n"
+
"\n|{BOARDING PASS}|"
+
"\\n--------------------------"
+
"\n\t|{BOARDING PASS}|"
+
"\n Name: "
+
first
+
" "
+
last
+
"\n Name: "
+
first
+
" "
+
last
+
"\n From: "
+
city
+
"\n From: "
+
city
+
"\n To: "
+
destination
+
"\n To: "
+
destination
+
"\n Flight:
"
+
"\n Flight:
FL"
+
randomflightnum
(
1
,
28
)
+
"\n Seat No.: "
+
reserve
+
"\n Seat No.: "
+
reserve
+
"\n Section: "
+
section
+
"\n Section: "
+
section
+
"\n--------------------------"
);
+
"\n--------------------------"
);
System
.
out
.
println
(
"Thanks for using our booking service"
);
System
.
out
.
println
(
"Thanks for using our booking service"
+
"\n Updated Plane seat plan:-"
);
display
(
plane
);
display
(
plane
);
}
}
void
main
()
{
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