Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AirlineReservation
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
alexandru.radulescu
AirlineReservation
Commits
43fb16b8
Commit
43fb16b8
authored
Nov 04, 2019
by
alexandru.radulesc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added comments
parent
4b062ccc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
34 deletions
+29
-34
Yeyey1.java
src/Yeyey1.java
+29
-34
No files found.
src/Yeyey1.java
View file @
43fb16b8
...
...
@@ -3,13 +3,13 @@ import java.util.Scanner;
public
class
Yeyey1
{
static
Scanner
input
=
new
Scanner
(
System
.
in
);
//We're just setting up the input for now;
static
String
[]
seat
=
new
String
[
100
];
static
int
j
=
0
,
k
=
0
,
mainSeatNumber
=
0
,
classRead
;
static
String
personName
;
static
String
[]
seat
=
new
String
[
100
];
//Seat array
static
int
j
=
0
,
k
=
0
,
mainSeatNumber
=
0
,
classRead
;
//Seat number and seat class, both inputs from the user
static
String
personName
;
// name, destination and city, will be printed on the boarding pass
static
String
destination
;
static
String
currentCity
;
static
String
[]
planeName
=
new
String
[
28
];
static
int
bookAgain
=
1
;
static
int
bookAgain
=
1
;
// variable to check if the user wants to book another seat
public
static
void
main
(
String
[]
args
)
{
...
...
@@ -20,7 +20,7 @@ public class Yeyey1 {
{
seat
[
i
]
=
"0"
+
String
.
valueOf
(
i
+
1
);
}
}
}
//here we set up the numbers for the seats
for
(
int
i
=
0
;
i
<
28
;
i
++)
{
...
...
@@ -30,38 +30,35 @@ public class Yeyey1 {
}
else
planeName
[
i
]
=
"FL"
+
(
i
+
1
);
}
}
//here we set up the flight names
GiveInfo
();
GiveInfo
();
//here we ask the user for his info
while
(
true
)
{
if
(
bookAgain
==
1
)
if
(
bookAgain
==
1
)
//if the user wishes to book
{
System
.
out
.
println
(
""
);
System
.
out
.
println
(
"For First Class please input 1"
);
System
.
out
.
println
(
"For Business Class please input 2"
);
System
.
out
.
println
(
"For Economy Class please input 3"
);
classRead
=
input
.
nextInt
();
BookSeats
(
classRead
);
classRead
=
input
.
nextInt
();
//we ask for his class
BookSeats
(
classRead
);
//and pass it over to booking the respective seat
System
.
out
.
println
(
""
);
System
.
out
.
println
(
"Would you like to book another seat? 0 = no / 1 = yes"
);
bookAgain
=
input
.
nextInt
();
bookAgain
=
input
.
nextInt
();
//ask the user if he wishes to book again
}
else
if
(
bookAgain
==
0
)
else
if
(
bookAgain
==
0
)
//if not, we show his boarding pass and exit
{
ShowBoardingPass
();
System
.
out
.
println
(
"Have a good day!"
);
break
;
}
}
}
public
static
void
BookSeats
(
int
mainClass
)
//Method for a
dding the seats and displaying them yey
public
static
void
BookSeats
(
int
mainClass
)
//Method for a
sking the user for his seat number
{
if
(
mainClass
==
1
)
...
...
@@ -87,16 +84,15 @@ public class Yeyey1 {
}
}
public
static
void
AssignSeats
(
int
start
,
int
finish
)
{
for
(
int
i
=
start
;
i
<
finish
;
i
++)
public
static
void
AssignSeats
(
int
start
,
int
finish
)
//method for assigning seats and adding the changes to
{
//them (if they're occupied)
for
(
int
i
=
start
;
i
<
finish
;
i
++)
//start and finish are assigned in the ShowSeats method
{
if
(
k
<
9
)
{
if
(
j
<
3
)
{
if
(
i
<
9
)
System
.
out
.
print
(
"["
+
seat
[
i
]
+
"]"
);
else
System
.
out
.
print
(
"["
+
seat
[
i
]
+
"]"
);
System
.
out
.
print
(
"["
+
seat
[
i
]
+
"]"
);
j
++;
}
if
(
j
==
3
)
...
...
@@ -122,7 +118,7 @@ public class Yeyey1 {
System
.
out
.
println
(
"---------------FIRST CLASS----------------"
);
System
.
out
.
println
(
""
);
AssignSeats
(
0
,
18
);
AssignSeats
(
0
,
18
);
//for efficiency we only modify the seats in the respective class, instead of rewriting all of them
System
.
out
.
println
(
""
);
System
.
out
.
println
(
"--------------BUSINESS CLASS--------------"
);
...
...
@@ -137,24 +133,23 @@ public class Yeyey1 {
AssignSeats
(
45
,
90
);
}
public
static
void
OccupySeats
()
public
static
void
OccupySeats
()
//method for displaying the occupied seats
{
mainSeatNumber
=
input
.
nextInt
();
if
(
seat
[
mainSeatNumber
-
1
]
!=
"XX"
)
if
(
seat
[
mainSeatNumber
-
1
]
!=
"XX"
)
//we verify if the seat is already taken
{
seat
[
mainSeatNumber
-
1
]
=
"XX"
;
seat
[
mainSeatNumber
-
1
]
=
"XX"
;
//if not, occupy it and show the seats
ShowSeats
();
}
else
{
System
.
out
.
println
(
"Seat is already occupied"
);
System
.
out
.
println
(
"Seat is already occupied"
);
//if it is, tell the user the seat is occupied
}
}
public
static
void
GiveInfo
()
public
static
void
GiveInfo
()
//method for taking the user's info and displaying the seats for the first time
{
System
.
out
.
println
(
"Welcome to our online booking system"
);
System
.
out
.
print
(
"Please enter your name: "
);
personName
=
input
.
nextLine
();
System
.
out
.
print
(
"Please enter your city: "
);
...
...
@@ -164,15 +159,15 @@ public class Yeyey1 {
ShowSeats
();
}
public
static
void
ShowBoardingPass
()
public
static
void
ShowBoardingPass
()
//method for displaying the boarding pass
{
System
.
out
.
println
(
""
);
System
.
out
.
println
(
" -------------BOARDING PASS-----------------"
);
System
.
out
.
println
(
" Name:
"
+
personName
+
" ------------------"
);
System
.
out
.
println
(
" Current City:
"
+
currentCity
+
" ---------"
);
System
.
out
.
println
(
" Destination:
"
+
destination
+
" ----------"
);
System
.
out
.
println
(
" Seat:
"
+
mainSeatNumber
+
" --------"
);
System
.
out
.
println
(
" Flight:
"
+
planeName
[
0
]
+
" -----------------"
);
System
.
out
.
println
(
" Name:
---------- "
+
personName
);
System
.
out
.
println
(
" Current City:
-- "
+
currentCity
);
System
.
out
.
println
(
" Destination:
--- "
+
destination
);
System
.
out
.
println
(
" Seat:
---------- "
+
mainSeatNumber
);
System
.
out
.
println
(
" Flight:
-------- "
+
planeName
[
0
]
);
System
.
out
.
println
(
" -------------------------------------------"
);
System
.
out
.
println
(
""
);
}
...
...
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