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
26aeab05
Commit
26aeab05
authored
Nov 04, 2019
by
jonathan.craske
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
l
parents
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
176 additions
and
0 deletions
+176
-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
flightbooking.java
src/flightbooking/flightbooking.java
+141
-0
No files found.
.classpath
0 → 100644
View file @
26aeab05
<?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 @
26aeab05
/bin/
.project
0 → 100644
View file @
26aeab05
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>
flightbooking
</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 @
26aeab05
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/flightbooking/flightbooking.java
0 → 100644
View file @
26aeab05
package
flightbooking
;
import
java.util.Scanner
;
public
class
flightbooking
{
public
static
Scanner
input
=
new
Scanner
(
System
.
in
);
public
static
int
userInput
;
public
static
String
selectSeat
;
public
static
boolean
seatTaken
=
false
;
public
static
String
name
;
public
static
String
originDestination
;
public
static
String
destination
;
public
static
int
flightNum
=
01
;
public
static
String
[][]
first_class
=
new
String
[
9
][
2
];
public
static
String
[][]
business_class
=
new
String
[
9
][
3
];
public
static
String
[][]
economy_class
=
new
String
[
9
][
5
];
public
static
int
numberAssigner
=
1
;
public
static
void
main
(
String
[]
args
)
{
populateSeatNum
(
first_class
);
populateSeatNum
(
business_class
);
populateSeatNum
(
economy_class
);
menuChoice
();
}
//function for generating boarding pass
public
static
void
boardingPass
()
{
System
.
out
.
println
(
"|[ BOARDING PASS ]|"
);
System
.
out
.
println
(
"Name :"
+
name
);
System
.
out
.
println
(
"From :"
+
originDestination
);
System
.
out
.
println
(
"Destination :"
+
destination
);
System
.
out
.
println
(
"Flight :"
+
flightNum
);
System
.
out
.
println
(
"Seat No :"
+
selectSeat
);
System
.
out
.
println
(
"Section :FL"
+
flightNum
);
flightNum
++;
}
//function to assign a seat
public
static
void
chooseSeat
(
String
[][]
seats
)
{
System
.
out
.
println
(
"Enter seat you wish to book > "
);
selectSeat
=
input
.
next
();
for
(
int
i
=
0
;
i
<
seats
[
0
].
length
;
i
++)
{
if
(
seatTaken
==
true
)
{
break
;
}
for
(
int
j
=
0
;
j
<
seats
.
length
;
j
++)
{
// assigns seat if it is free
if
(
selectSeat
.
equals
(
seats
[
j
][
i
]))
{
seats
[
j
][
i
]
=
"XX"
;
seatTaken
=
true
;
if
(
seatTaken
==
true
)
{
System
.
out
.
println
(
"Seat "
+
selectSeat
+
" booked"
);
boardingPass
();
break
;
}
classAssigner
(
seats
);
}
}
}
}
// function for menu choices
public
static
void
menuChoice
()
{
//menu for classes
System
.
out
.
println
(
"Please enter name > "
);
name
=
input
.
next
();
System
.
out
.
println
(
"City of Origin > "
);
originDestination
=
input
.
next
();
System
.
out
.
println
(
"Destination travelling to > "
);
destination
=
input
.
next
();
System
.
out
.
println
(
"please choose which class you would like,\n"
+
"1 for first class,\n"
+
"2 for business class, \n"
+
"3 for economy class, \n "
);
int
customerChoice
=
input
.
nextInt
();
switch
(
customerChoice
)
{
case
1
:
classAssigner
(
first_class
);
break
;
case
2
:
classAssigner
(
business_class
);
break
;
case
3
:
classAssigner
(
economy_class
);
break
;
}
}
// assign and create seat charts for each class
public
static
void
classAssigner
(
String
[][]
assignClass
)
{
int
counter
=
1
;
for
(
int
column
=
0
;
column
<
assignClass
[
0
].
length
;
column
++)
{
counter
=
1
;
for
(
int
row
=
0
;
row
<
assignClass
.
length
;
row
++)
{
if
(
counter
>
3
)
{
System
.
out
.
print
(
" "
+
"["
+
assignClass
[
row
][
column
]
+
"]"
+
""
);
counter
=
1
;
}
else
{
System
.
out
.
print
(
"["
+
assignClass
[
row
][
column
]
+
"]"
+
""
);
}
counter
++;
}
System
.
out
.
println
();
}
chooseSeat
(
assignClass
);
}
//Initialize 2-D array which is called seatClass
public
static
void
populateSeatNum
(
String
[][]
seatAssign
)
{
for
(
int
column
=
0
;
column
<
seatAssign
[
0
].
length
;
column
++)
{
for
(
int
row
=
0
;
row
<
seatAssign
.
length
;
row
++)
{
seatAssign
[
row
][
column
]
=
Integer
.
toString
(
numberAssigner
);
numberAssigner
++;
}
}
}
}
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