Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
airlinereservationassessment
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
lucy.hemingway
airlinereservationassessment
Commits
bcd591b3
Commit
bcd591b3
authored
Nov 03, 2019
by
lucy.hemingway
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished version
parents
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
233 additions
and
0 deletions
+233
-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
assessment.java
src/airlinereservation/assessment.java
+198
-0
No files found.
.classpath
0 → 100644
View file @
bcd591b3
<?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 @
bcd591b3
/bin/
.project
0 → 100644
View file @
bcd591b3
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>
airlinereservation
</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 @
bcd591b3
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/airlinereservation/assessment.java
0 → 100644
View file @
bcd591b3
package
airlinereservation
;
import
java.util.*
;
public
class
assessment
{
public
static
void
main
(
String
[]
args
)
{
// TODO Auto-generated method stub
// TODO Auto-generated method stub
//hired to develop a new system for an automated reservations system
// 28 flights a week, one every 6 hours
// 90 seats per flight
//ask customer first name
Scanner
userInputScanner
=
new
Scanner
(
System
.
in
);
System
.
out
.
println
(
"Airline seat reservation - Customer details:"
);
System
.
out
.
print
(
" First Name: "
);
//string
String
firstname
;
firstname
=
userInputScanner
.
next
();
//ask for last name
System
.
out
.
print
(
" Last Name: "
);
// string
String
lastname
;
lastname
=
userInputScanner
.
next
();
// ask for origin city
System
.
out
.
print
(
" Origin City: "
);
//string
String
origincity
;
origincity
=
userInputScanner
.
next
();
// ask for destination city
System
.
out
.
print
(
" City of Destination: "
);
//string
String
destinationcity
;
destinationcity
=
userInputScanner
.
next
();
//generate random flight number between 1 and 28
Random
random
=
new
Random
();
System
.
out
.
println
(
"Your Flight number is FL"
+
random
.
nextInt
(
28
+
1
));
//save this as variable to use on boarding pass
int
flightnumber
;
flightnumber
=
random
.
nextInt
(
28
+
1
);
//create an array with the seat numbers to choose from
String
boardingseats
[][]
={{
"01"
,
"02"
,
"03"
,
"04"
,
"05"
,
"06"
,
"07"
,
"08"
,
"09"
},
{
"10"
,
"11"
,
"12"
,
"13"
,
"14"
,
"15"
,
"16"
,
"17"
,
"18"
},
{
"19"
,
"20"
,
"21"
,
"22"
,
"23"
,
"24"
,
"25"
,
"26"
,
"27"
},
{
"28"
,
"29"
,
"30"
,
"31"
,
"32"
,
"33"
,
"34"
,
"35"
,
"36"
},
{
"37"
,
"38"
,
"39"
,
"40"
,
"41"
,
"42"
,
"43"
,
"44"
,
"45"
},
{
"46"
,
"47"
,
"48"
,
"49"
,
"50"
,
"51"
,
"52"
,
"53"
,
"54"
},
{
"55"
,
"56"
,
"57"
,
"58"
,
"59"
,
"60"
,
"61"
,
"62"
,
"63"
},
{
"64"
,
"65"
,
"66"
,
"67"
,
"68"
,
"69"
,
"70"
,
"71"
,
"72"
},
{
"73"
,
"74"
,
"75"
,
"76"
,
"77"
,
"78"
,
"79"
,
"80"
,
"81"
},
{
"82"
,
"83"
,
"84"
,
"85"
,
"86"
,
"87"
,
"88"
,
"89"
,
"90"
}};
//print the seating chart, using method show
show
(
boardingseats
);
//asking what class - first class, business and economy
System
.
out
.
println
(
"Please type 1 for First Class"
);
System
.
out
.
println
(
"Please type 2 for Business"
);
System
.
out
.
println
(
"Please type 3 for Economy"
);
// start of loop so if seat is taken, another can be chosen
while
(
true
)
{
int
alternatives
;
alternatives
=
userInputScanner
.
nextInt
();
//if statement for which number they choose
//first class
if
(
alternatives
==
1
)
{
System
.
out
.
println
(
"You have Selected First Class"
);
show
(
boardingseats
);
System
.
out
.
println
(
"To do this type the row the seat is on starting at 0"
);
System
.
out
.
println
(
"and how many seats across, also starting at 0"
);
}
//business
else
if
(
alternatives
==
2
)
{
System
.
out
.
println
(
"You have selected Business"
);
show
(
boardingseats
);
System
.
out
.
println
(
"Please choose an available seat between 19 and 45"
);
System
.
out
.
println
(
"To do this type the row the seat is on starting at 0"
);
System
.
out
.
println
(
"and how many seats across, also starting at 0"
);
}
//economy
else
if
(
alternatives
==
3
)
{
System
.
out
.
println
(
"You have selected Economy"
);
show
(
boardingseats
);
System
.
out
.
println
(
"To do this type the row the seat is on starting at 0"
);
System
.
out
.
println
(
"and how many seats across, also starting at 0"
);
}
//user inputs a row and column their seat is on to pick
// if the seat is not already XX, it becomes that
// if it is XX, ask to choose a different seat
int
x
,
y
;
x
=
userInputScanner
.
nextInt
();
y
=
userInputScanner
.
nextInt
();
if
(
boardingseats
[
x
][
y
]
!=
"XX"
)
{
boardingseats
[
x
][
y
]
=
"XX"
;
show
(
boardingseats
);
break
;
}
else
System
.
out
.
println
(
"This seat is taken, please start again"
);
System
.
out
.
println
(
"Please type 1 for First Class"
);
System
.
out
.
println
(
"Please type 2 for Business"
);
System
.
out
.
println
(
"Please type 3 for Economy"
);}
System
.
out
.
println
();
System
.
out
.
println
(
"Thankyou for your booking, here is your boarding pass"
);
System
.
out
.
println
(
"Please proceed to print the pass and bring it to the airport"
);
System
.
out
.
println
();
//create an array list to make a boarding pass
ArrayList
<
String
>
boardingpass
=
new
ArrayList
<
String
>();
boardingpass
.
add
(
"|[ BOARDING PASS ]|"
+
"\n"
);
//add all the elements required
boardingpass
.
add
(
"First name :"
+
firstname
+
"\n"
);
boardingpass
.
add
(
"Last name :"
+
lastname
+
"\n"
);
boardingpass
.
add
(
"Origin city :"
+
origincity
+
"\n"
);
boardingpass
.
add
(
"destination :"
+
destinationcity
+
"\n"
);
boardingpass
.
add
(
"Flight No. :FL"
+
flightnumber
);
//print the boarding pass for the customer
System
.
out
.
print
(
boardingpass
);
}
//method for showing the seating arrangement making it easier to access
static
void
show
(
String
boardingseats
[][])
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
j
=
0
;
j
<
9
;
j
++)
{
System
.
out
.
print
(
boardingseats
[
i
][
j
]
+
" "
);
}
System
.
out
.
println
();
}
}
}
lucy.hemingway
@lucy.hemingway
·
Nov 03, 2019
Maintainer
![Screenshot_2019-11-03_at_18.04.30](/uploads/d7bfa153895df2bc64a01a1092780051/Screenshot_2019-11-03_at_18.04.30.png)
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