Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
flight booking assignment
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
jonathan.craske
flight booking assignment
Commits
f433acdf
Commit
f433acdf
authored
Nov 04, 2019
by
jonathan.craske
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update flightbooking.java
parent
a8cc2090
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
19 deletions
+26
-19
flightbooking.java
src/flightbooking/flightbooking.java
+26
-19
No files found.
src/flightbooking/flightbooking.java
View file @
f433acdf
package
flightbooking
;
package
flightbooking
;
// importing scanner
import
java.util.Scanner
;
import
java.util.Scanner
;
public
class
flightbooking
{
public
class
flightbooking
{
// declaring the name of the scanner
public
static
Scanner
input
=
new
Scanner
(
System
.
in
);
public
static
Scanner
input
=
new
Scanner
(
System
.
in
);
// declaring public variables
public
static
int
userInput
;
public
static
int
userInput
;
public
static
String
selectSeat
;
public
static
int
flightNum
=
01
;
public
static
boolean
seatTaken
=
false
;
public
static
boolean
seatUsed
=
false
;
public
static
String
pickSeat
;
public
static
String
name
;
public
static
String
name
;
public
static
String
originDestination
;
public
static
String
start
;
public
static
String
destination
;
public
static
String
destination
;
public
static
int
flightNum
=
01
;
public
static
String
[][]
first_class
=
new
String
[
9
][
2
];
public
static
String
[][]
first_class
=
new
String
[
9
][
2
];
public
static
String
[][]
business_class
=
new
String
[
9
][
3
];
public
static
String
[][]
business_class
=
new
String
[
9
][
3
];
...
@@ -27,12 +31,13 @@ public static int numberAssigner = 1;
...
@@ -27,12 +31,13 @@ public static int numberAssigner = 1;
//function for generating boarding pass
//function for generating boarding pass
public
static
void
boardingPass
()
public
static
void
boardingPass
()
{
{
// printing out a boarding pass to the user
System
.
out
.
println
(
"|[ BOARDING PASS ]|"
);
System
.
out
.
println
(
"|[ BOARDING PASS ]|"
);
System
.
out
.
println
(
"Name :"
+
name
);
System
.
out
.
println
(
"Name :"
+
name
);
System
.
out
.
println
(
"From :"
+
originDestination
);
System
.
out
.
println
(
"From :"
+
start
);
System
.
out
.
println
(
"Destination :"
+
destination
);
System
.
out
.
println
(
"Destination :"
+
destination
);
System
.
out
.
println
(
"Flight :"
+
flightNum
);
System
.
out
.
println
(
"Flight :"
+
flightNum
);
System
.
out
.
println
(
"Seat No :"
+
select
Seat
);
System
.
out
.
println
(
"Seat No :"
+
pick
Seat
);
System
.
out
.
println
(
"Section :FL"
+
flightNum
);
System
.
out
.
println
(
"Section :FL"
+
flightNum
);
flightNum
++;
flightNum
++;
}
}
...
@@ -40,25 +45,26 @@ public static int numberAssigner = 1;
...
@@ -40,25 +45,26 @@ public static int numberAssigner = 1;
//function to assign a seat
//function to assign a seat
public
static
void
chooseSeat
(
String
[][]
seats
)
public
static
void
chooseSeat
(
String
[][]
seats
)
{
{
// getting user to choose their seat
System
.
out
.
println
(
"Enter seat you wish to book > "
);
System
.
out
.
println
(
"Enter seat you wish to book > "
);
select
Seat
=
input
.
next
();
pick
Seat
=
input
.
next
();
for
(
int
i
=
0
;
i
<
seats
[
0
].
length
;
i
++)
for
(
int
i
=
0
;
i
<
seats
[
0
].
length
;
i
++)
{
{
if
(
seat
Taken
==
true
)
if
(
seat
Used
==
true
)
{
{
break
;
break
;
}
}
for
(
int
j
=
0
;
j
<
seats
.
length
;
j
++)
for
(
int
j
=
0
;
j
<
seats
.
length
;
j
++)
{
{
// assigns seat if it is free
// assigns seat if it is free
if
(
select
Seat
.
equals
(
seats
[
j
][
i
]))
if
(
pick
Seat
.
equals
(
seats
[
j
][
i
]))
{
{
seats
[
j
][
i
]
=
"XX"
;
seats
[
j
][
i
]
=
"XX"
;
seat
Taken
=
true
;
seat
Used
=
true
;
if
(
seat
Taken
==
true
)
if
(
seat
Used
==
true
)
{
{
System
.
out
.
println
(
"Seat "
+
select
Seat
+
" booked"
);
System
.
out
.
println
(
"Seat "
+
pick
Seat
+
" booked"
);
boardingPass
();
boardingPass
();
break
;
break
;
}
}
...
@@ -71,14 +77,15 @@ public static int numberAssigner = 1;
...
@@ -71,14 +77,15 @@ public static int numberAssigner = 1;
// function for menu choices
// function for menu choices
public
static
void
menuChoice
()
public
static
void
menuChoice
()
{
{
//
menu for classes
//
getting details about the users journey
System
.
out
.
println
(
"Please enter name > "
);
System
.
out
.
println
(
"Please enter name > "
);
name
=
input
.
next
();
name
=
input
.
next
();
System
.
out
.
println
(
"
City of Origi
n > "
);
System
.
out
.
println
(
"
Start locatio
n > "
);
originDestination
=
input
.
next
();
start
=
input
.
next
();
System
.
out
.
println
(
"Des
tination travelling to
> "
);
System
.
out
.
println
(
"Des
ired destination
> "
);
destination
=
input
.
next
();
destination
=
input
.
next
();
// getting the user to decide which section they want to sit in
System
.
out
.
println
(
"please choose which class you would like,\n"
System
.
out
.
println
(
"please choose which class you would like,\n"
+
"1 for first class,\n"
+
"1 for first class,\n"
+
"2 for business class, \n"
+
"2 for business class, \n"
...
@@ -98,7 +105,7 @@ public static int numberAssigner = 1;
...
@@ -98,7 +105,7 @@ public static int numberAssigner = 1;
}
}
}
}
// assign and create seat
charts
for each class
// assign and create seat
ing plan
for each class
public
static
void
classAssigner
(
String
[][]
assignClass
)
public
static
void
classAssigner
(
String
[][]
assignClass
)
{
{
int
counter
=
1
;
int
counter
=
1
;
...
@@ -123,7 +130,7 @@ public static int numberAssigner = 1;
...
@@ -123,7 +130,7 @@ public static int numberAssigner = 1;
chooseSeat
(
assignClass
);
chooseSeat
(
assignClass
);
}
}
//
Initialize 2-D array which is called seatClass
//
initialize 2d array
public
static
void
populateSeatNum
(
String
[][]
seatAssign
)
public
static
void
populateSeatNum
(
String
[][]
seatAssign
)
{
{
for
(
int
column
=
0
;
column
<
seatAssign
[
0
].
length
;
column
++)
for
(
int
column
=
0
;
column
<
seatAssign
[
0
].
length
;
column
++)
...
...
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