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
942b82f1
Commit
942b82f1
authored
Oct 29, 2019
by
alexandru.radulesc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Seat booking is ok
parent
7751fe2b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
22 deletions
+69
-22
Yeyey1.java
src/Yeyey1.java
+69
-22
No files found.
src/Yeyey1.java
View file @
942b82f1
...
...
@@ -4,49 +4,75 @@ import java.util.Scanner;
public
class
Yeyey1
{
//--------------------------------------------------Setup Phase--------------------------------------------------\\
Scanner
input
=
new
Scanner
(
System
.
in
);
//We're just setting up the input for now;
static
int
[]
seat
=
new
int
[
100
];
static
int
j
=
0
,
k
=
0
;
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
;
public
static
void
main
(
String
[]
args
)
{
// TODO Auto-generated method stub
System
.
out
.
println
(
""
);
System
.
out
.
println
(
"---------------FIRST CLASS----------------"
);
System
.
out
.
println
(
""
);
for
(
int
i
=
0
;
i
<
90
;
i
++)
{
seat
[
i
]
=
String
.
valueOf
(
i
+
1
);
if
(
i
<
9
)
{
seat
[
i
]
=
"0"
+
String
.
valueOf
(
i
+
1
);
}
ShowSeats
(
0
,
18
);
}
System
.
out
.
println
(
""
);
System
.
out
.
println
(
"--------------BUSINESS CLASS--------------"
);
System
.
out
.
println
(
""
);
ShowSeats
();
ShowSeats
(
18
,
45
);
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
();
System
.
out
.
println
(
""
);
System
.
out
.
println
(
"---------------ECONOMY CLASS--------------"
);
System
.
out
.
println
(
""
);
BookSeats
(
classRead
);
ShowSeats
(
45
,
90
);
ShowSeats
();
}
public
static
void
BookSeats
(
int
classNum
)
//Method for adding the seats and displaying them yey
public
static
void
BookSeats
(
int
mainClass
)
//Method for adding the seats and displaying them yey
{
if
(
mainClass
==
1
)
{
System
.
out
.
println
(
"Please select a seat from 01 to 18"
);
{
mainSeatNumber
=
input
.
nextInt
();
seat
[
mainSeatNumber
-
1
]
=
"XX"
;
}
}
else
if
(
mainClass
==
2
)
{
System
.
out
.
println
(
"Please select a seat from 19 to 45"
);
{
mainSeatNumber
=
input
.
nextInt
();
seat
[
mainSeatNumber
-
1
]
=
"XX"
;
}
}
else
if
(
mainClass
==
3
)
{
System
.
out
.
println
(
"Please select a seat from 46 to 90"
);
{
mainSeatNumber
=
input
.
nextInt
();
seat
[
mainSeatNumber
-
1
]
=
"XX"
;
}
}
}
public
static
void
Show
Seats
(
int
start
,
int
finish
)
public
static
void
Assign
Seats
(
int
start
,
int
finish
)
{
for
(
int
i
=
start
;
i
<
finish
;
i
++)
{
seat
[
i
]
=
i
+
1
;
if
(
k
<
9
)
{
if
(
j
<
3
)
{
if
(
i
<
9
)
System
.
out
.
print
(
"[
0
"
+
seat
[
i
]
+
"]"
);
if
(
i
<
9
)
System
.
out
.
print
(
"["
+
seat
[
i
]
+
"]"
);
else
System
.
out
.
print
(
"["
+
seat
[
i
]
+
"]"
);
j
++;
}
...
...
@@ -67,4 +93,25 @@ public class Yeyey1 {
}
}
public
static
void
ShowSeats
()
{
System
.
out
.
println
(
""
);
System
.
out
.
println
(
"---------------FIRST CLASS----------------"
);
System
.
out
.
println
(
""
);
AssignSeats
(
0
,
18
);
System
.
out
.
println
(
""
);
System
.
out
.
println
(
"--------------BUSINESS CLASS--------------"
);
System
.
out
.
println
(
""
);
AssignSeats
(
18
,
45
);
System
.
out
.
println
(
""
);
System
.
out
.
println
(
"---------------ECONOMY CLASS--------------"
);
System
.
out
.
println
(
""
);
AssignSeats
(
45
,
90
);
}
}
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