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
thomas.barraclough
AirlineReservation
Commits
0af9c23d
Commit
0af9c23d
authored
Nov 04, 2019
by
Tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Final Version of code
parent
1a42f6d2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
179 additions
and
9 deletions
+179
-9
Airplane_class.java
Airplan_project/src/Airplane_class.java
+176
-7
test.java
Airplan_project/src/test.java
+3
-2
No files found.
Airplan_project/src/Airplane_class.java
View file @
0af9c23d
...
@@ -20,6 +20,8 @@ public class Airplane_class {
...
@@ -20,6 +20,8 @@ public class Airplane_class {
//this int is for choosing a seat
//this int is for choosing a seat
int
seat
;
int
seat
;
int
end
;
//Here I start a loop so that I can transfer the user back to here when needed
//Here I start a loop so that I can transfer the user back to here when needed
...
@@ -72,18 +74,66 @@ public class Airplane_class {
...
@@ -72,18 +74,66 @@ public class Airplane_class {
//This prints a sentence to the screen
//This prints a sentence to the screen
System
.
out
.
println
(
"\n\n\n\n\n\nYou have chosen First Class\n"
);
System
.
out
.
println
(
"\n\n\n\n\n\nYou have chosen First Class\n"
);
System
.
out
.
println
(
"Would you like to choose a seat? type y for yes or n for no "
);
System
.
out
.
println
(
"Would you like to choose a seat? type y for yes or n for no "
);
//This allows the user to enter a letter
yesOrNo
=
input
.
next
();
yesOrNo
=
input
.
next
();
//if the user entered y, the following code will take place
if
(
yesOrNo
.
equals
(
"y"
))
{
if
(
yesOrNo
.
equals
(
"y"
))
{
System
.
out
.
println
(
"Please select a seat between 1-18, enter then number of the seat you would like\n"
);
System
.
out
.
println
(
"Please select a seat between 1-18, enter then number of the seat you would like\n"
);
//Allows the user to input the seat they want
seat
=
input
.
nextInt
();
seat
=
input
.
nextInt
();
System
.
out
.
println
(
"You chose seat number "
+
seat
+
"!"
);
//This checks to see if the seat is within the parameters
if
(
seat
<
19
&&
seat
>
0
)
{
System
.
out
.
print
(
"\n\n\n\n\n\n\nThank you for flying with us today, here is your boarding pass\n\n"
+
"---Boarding Pass---"
+
"\nName : "
+
name
+
"\nFrom : "
+
origin
+
"\nTo : "
+
destination
+
"\nFlight : FL"
+
FL
+
"\nSeat No : "
+
seat
+
"\nSection : First Class\n\n\n\n\n\n"
);
System
.
out
.
print
(
"\nEnter 1 to book another flight or press 2 to end application\n\n"
);
end
=
input
.
nextInt
();
//checks if the user entered 2, if they did the program will close
if
(
end
==
2
)
{
return
;
}
}
//if the if statement from earlier (the parameter checking one) finds that the selected seat is not in the
//parameter, the else statement will run, this displays a message and ends the program
}
else
{
System
.
out
.
println
(
"Seat not within parameters"
);
return
;
}
}
//if the yerOrNo input equals n, the following code will run
if
(
yesOrNo
.
equals
(
"n"
))
{
if
(
yesOrNo
.
equals
(
"n"
))
{
System
.
out
.
println
(
"you chose no"
);
seat
=
0
;
seat
++;
System
.
out
.
print
(
"\n\n\n\n\n\n\nThank you for flying with us today, here is your boarding pass\n\n"
+
"---Boarding Pass---"
+
"\nName : "
+
name
+
"\nFrom : "
+
origin
+
"\nTo : "
+
destination
+
"\nFlight : FL"
+
FL
+
"\nSeat No : "
+
seat
+
"\nSection : First Class\n\n\n\n\n\n"
);
System
.
out
.
print
(
"\nEnter 1 to book another flight or press 2 to end application\n\n"
);
//Allows the user to input a numerical value
end
=
input
.
nextInt
();
//if the user input is equal to 2, the program will close
if
(
end
==
2
)
{
return
;
}
}
}
...
@@ -93,12 +143,131 @@ public class Airplane_class {
...
@@ -93,12 +143,131 @@ public class Airplane_class {
break
;
break
;
//My second case is for the business section of the plane
//My second case is for the business section of the plane
case
2
:
case
2
:
System
.
out
.
println
(
"\\n\\n\\n\\n\\n\\nYou have chosen Business"
);
System
.
out
.
println
(
"\n\n\n\n\n\nYou have chosen Business"
);
System
.
out
.
println
(
"Would you like to choose a seat? type y for yes or n for no "
);
//Allows the user to input a string
yesOrNo
=
input
.
next
();
//if the condition is met the following code will run
if
(
yesOrNo
.
equals
(
"y"
))
{
//Allows the user to enter a seat number, if the seat number is within the chosen parameters, the code if statement will run
System
.
out
.
println
(
"Please select a seat between 19-45, enter then number of the seat you would like\n"
);
seat
=
input
.
nextInt
();
if
(
seat
<
46
&&
seat
>
18
)
{
System
.
out
.
print
(
"\n\n\n\n\n\n\nThank you for flying with us today, here is your boarding pass\n\n"
+
"---Boarding Pass---"
+
"\nName : "
+
name
+
"\nFrom : "
+
origin
+
"\nTo : "
+
destination
+
"\nFlight : FL"
+
FL
+
"\nSeat No : "
+
seat
+
"\nSection : Business\n\n\n\n\n\n"
);
//Allows the user to end a number, this decides if the user will book another flight or close the program
System
.
out
.
print
(
"\nEnter 1 to book another flight or press 2 to end application\n\n"
);
end
=
input
.
nextInt
();
if
(
end
==
2
)
{
return
;
}
//If the number entered earlier is not within the parameters then the program will end
}
else
{
System
.
out
.
println
(
"Seat not within parameters"
);
return
;
}
}
//If the user entered n in the earlier choice this screen will be displayed, here the seat value is set to 18 and then
//is added to by 1 every time this code is gone through
if
(
yesOrNo
.
equals
(
"n"
))
{
seat
=
18
;
seat
++;
System
.
out
.
print
(
"\n\n\n\n\n\n\nThank you for flying with us today, here is your boarding pass\n\n"
+
"---Boarding Pass---"
+
"\nName : "
+
name
+
"\nFrom : "
+
origin
+
"\nTo : "
+
destination
+
"\nFlight : FL"
+
FL
+
"\nSeat No : "
+
seat
+
"\nSection : First Class\n\n\n\n\n\n"
);
System
.
out
.
print
(
"\nEnter 1 to book another flight or press 2 to end application\n\n"
);
end
=
input
.
nextInt
();
if
(
end
==
2
)
{
return
;
}
}
break
;
break
;
//This case is used for the economy section of the plane
//This case is used for the economy section of the plane
case
3
:
case
3
:
System
.
out
.
println
(
"\n\n\n\n\n\nYou have chosen Economy"
);
System
.
out
.
println
(
"\n\n\n\n\n\nYou have chosen Economy"
);
System
.
out
.
println
(
"Would you like to choose a seat? type y for yes or n for no "
);
//The user is prompted to enter a letter, if the letter is y the following code runs
yesOrNo
=
input
.
next
();
if
(
yesOrNo
.
equals
(
"y"
))
{
System
.
out
.
println
(
"Please select a seat between 46-70, enter then number of the seat you would like\n"
);
//This allows the user to enter a numerical value to choose a seat number, if the seat number chosen is within the
//parameter, the following if statement plays
seat
=
input
.
nextInt
();
if
(
seat
<
71
&&
seat
>
45
)
{
System
.
out
.
print
(
"\n\n\n\n\n\n\nThank you for flying with us today, here is your boarding pass\n\n"
+
"---Boarding Pass---"
+
"\nName : "
+
name
+
"\nFrom : "
+
origin
+
"\nTo : "
+
destination
+
"\nFlight : FL"
+
FL
+
"\nSeat No : "
+
seat
+
"\nSection : Economy\n\n\n\n\n\n"
);
System
.
out
.
print
(
"\nEnter 1 to book another flight or press 2 to end application\n\n"
);
//This allows the user to enter a digit to decide if the would like to make another booking or just close the application
//If two is entered, the application will close, if one is entered, the code will start from the beginning
end
=
input
.
nextInt
();
if
(
end
==
2
)
{
return
;
}
}
else
{
System
.
out
.
println
(
"Seat not within parameters"
);
return
;
}
}
//This if statement is run if the user entered n instead of y earlier
if
(
yesOrNo
.
equals
(
"n"
))
{
seat
=
45
;
seat
++;
System
.
out
.
print
(
"\n\n\n\n\n\n\nThank you for flying with us today, here is your boarding pass\n\n"
+
"---Boarding Pass---"
+
"\nName : "
+
name
+
"\nFrom : "
+
origin
+
"\nTo : "
+
destination
+
"\nFlight : FL"
+
FL
+
"\nSeat No : "
+
seat
+
"\nSection : First Class\n\n\n\n\n\n"
);
System
.
out
.
print
(
"\nEnter 1 to book another flight or press 2 to end application\n\n"
);
end
=
input
.
nextInt
();
if
(
end
==
2
)
{
return
;
}
}
break
;
break
;
...
...
Airplan_project/src/test.java
View file @
0af9c23d
...
@@ -5,11 +5,13 @@ public class test {
...
@@ -5,11 +5,13 @@ public class test {
public
static
Scanner
input
=
new
Scanner
(
System
.
in
);
public
static
Scanner
input
=
new
Scanner
(
System
.
in
);
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
// TODO Auto-generated method stub
// TODO Auto-generated method stub
int
day
;
int
day
;
day
=
input
.
nextInt
();
day
=
input
.
nextInt
();
switch
(
day
)
{
switch
(
day
)
{
...
@@ -17,8 +19,7 @@ public class test {
...
@@ -17,8 +19,7 @@ public class test {
}
}
switch
(
day
)
{
switch
(
day
)
{
case
1
:
case
1
:
System
.
out
.
println
(
"Monddsd"
);
break
;
case
2
:
case
2
:
System
.
out
.
println
(
"Msdsdsdsdsddsd"
);
System
.
out
.
println
(
"Msdsdsdsdsddsd"
);
...
...
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