Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AirlineReservation1
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
eren.beyazbayrak
AirlineReservation1
Commits
48697493
Commit
48697493
authored
Nov 04, 2019
by
Anon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished product :)
parent
e5b36dd5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
46 deletions
+78
-46
Book.java
PlaneBooking/src/Book.java
+78
-46
No files found.
PlaneBooking/src/Book.java
View file @
48697493
import
java.util.Scanner
;
import
java.util.Scanner
;
import
java.util.Random
;
import
java.util.Random
;
//import all of the functionality
import
java.text.DecimalFormat
;
import
java.util.Arrays
;
import
java.util.Arrays
;
public
class
Book
{
public
class
Book
{
private
char
[][]
Seat
;
static
String
[][]
seatArray
=
{
//The array is being created here
private
boolean
booked
=
false
;
{
"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"
},
// the array will visually represent each seat
};
static
String
name
=
""
;
static
String
city
=
""
;
static
String
dest
=
""
;
static
String
Flight
=
""
;
//these are in the global so they can be accessed easily
static
String
Seated
=
""
;
static
String
FlightClass
=
""
;
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
// TODO Auto-generated method stub
// TODO Auto-generated method stub
DecimalFormat
Format
=
new
DecimalFormat
(
"00"
);
Scanner
input
=
new
Scanner
(
System
.
in
);
Scanner
input
=
new
Scanner
(
System
.
in
);
Scanner
inputstring
=
new
Scanner
(
System
.
in
);
System
.
out
.
println
(
"Enter name: "
);
//user will input their informaiton for the plane
name
=
input
.
next
();
Seat
=
new
char
[
10
][
9
];
printSeat
();
System
.
out
.
println
(
"Enter name: "
);
String
name
=
input
.
next
();
System
.
out
.
println
(
"Enter Origin City: "
);
System
.
out
.
println
(
"Enter Origin City: "
);
String
city
=
input
.
next
();
city
=
input
.
next
();
System
.
out
.
println
(
"Enter Destination: "
);
System
.
out
.
println
(
"Enter Destination: "
);
String
dest
=
input
.
next
();
dest
=
input
.
next
();
//generate flight number
//Random flight number generator
Random
rando
=
new
Random
();
int
Flightnum
=
Generate
(
1
,
28
);
int
Flightnum
=
rando
.
nextInt
(
27
);
Flightnum
+=
1
;
System
.
out
.
println
(
"Your flight number is"
);
System
.
out
.
println
(
"Your flight number is"
);
System
.
out
.
println
(
"FL"
+
Flightnum
);
System
.
out
.
println
(
"FL"
+
Flightnum
);
Flight
=
"FL"
+
Flightnum
;
//Array
String
[][]
seat
=
new
String
[
9
][
10
];
booked
=
"XX"
;
//
Visual M
enu
//
This will print out the visual m
enu
System
.
out
.
println
(
"Choose what class you would like"
);
System
.
out
.
println
(
"Choose what class you would like"
);
System
.
out
.
println
(
"1\t First Class"
);
System
.
out
.
println
(
"1\t First Class"
);
System
.
out
.
println
(
"2\t Business Class"
);
System
.
out
.
println
(
"2\t Business Class"
);
System
.
out
.
println
(
"3\t Economy Class"
);
System
.
out
.
println
(
"3\t Economy Class"
);
System
.
out
.
println
(
"Your choice:"
);
System
.
out
.
println
(
"Your choice:"
);
//
inpu
t
//
the user will input what class they will wan
t
int
choice
=
input
.
nextInt
();
int
choice
=
input
.
nextInt
();
if
(
choice
==
1
)
{
if
(
choice
==
1
)
{
System
.
out
.
println
(
"You will get a seat between 1-18"
);
System
.
out
.
println
(
"You will get a seat between 1-18"
);
int
Picked
=
Generate
(
1
,
18
);
String
Seat
=
Format
.
format
(
Picked
);
String
Checked
=
Check
(
Seat
);
if
(
Checked
==
"Available"
){
System
.
out
.
println
(
"ur ticket is booked m8"
);
}
FlightClass
=
"First Class"
;
}
}
else
if
(
choice
==
2
)
{
else
if
(
choice
==
2
)
{
System
.
out
.
println
(
"You will get a seat between 19-45"
);
System
.
out
.
println
(
"You will get a seat between 19-45"
);
int
Picked
=
Generate
(
19
,
45
);
String
Seat
=
Format
.
format
(
Picked
);
String
Checked
=
Check
(
Seat
);
if
(
Checked
==
"Available"
){
System
.
out
.
println
(
"ur ticket is booked m8"
);
}
FlightClass
=
"Business"
;
}
}
else
else
if
(
choice
==
3
){
{
System
.
out
.
println
(
"You will get a seat between 46-90"
);
System
.
out
.
println
(
"You will get a seat between 46-90"
);
int
Picked
=
Generate
(
46
,
90
);
String
Seat
=
Format
.
format
(
Picked
);
String
Checked
=
Check
(
Seat
);
if
(
Checked
==
"Available"
){
System
.
out
.
println
(
"ur ticket is booked m8"
);
}
}
FlightClass
=
"Economy"
;
System
.
out
.
println
(
"Would you like to choose your seat? "
);
String
choice1
=
inputstring
.
nextLine
();
if
(
choice1
==
"yes"
)
{
}
}
System
.
out
.
println
(
"\n|[ Boarding Pass |]\n"
+
// boarding pass being created
"Name : "
+
name
+
"\nFrom : "
+
city
+
"\nTo : "
+
dest
+
"\nFlight Number : "
+
Flightnum
+
"\nSeat Number : "
+
Seated
+
"\nClass of flight : "
+
FlightClass
);
}
public
static
String
Check
(
String
SeatNo
)
{
//function being ready to be called back
String
Checked
=
"Unavailable"
;
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
j
=
0
;
j
<
9
;
j
++)
{
if
(
seatArray
[
i
][
j
]
.
equals
(
SeatNo
))
{
System
.
out
.
println
(
"your seat is : "
+
seatArray
[
i
][
j
]);
seatArray
[
i
][
j
]
=
"XX"
;
Checked
=
"Available"
;
Seated
=
SeatNo
;
return
Checked
;
}
}
}
return
Checked
;
//return the function
}
public
static
int
Generate
(
int
min
,
int
max
)
{
int
RandomNo
=
(
int
)
((
Math
.
random
()*((
max
-
min
)+
1
))+
min
);
return
RandomNo
;
// Random number generator for the flight tickets
}
}
}
}
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