Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
s7_bekman_i
AirportIS_2020
Commits
852d4779
Commit
852d4779
authored
Apr 09, 2020
by
Ieva
Browse files
Boarding Pass Updated
parent
d1137160
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
43 additions
and
16 deletions
+43
-16
bin/main/Main.class
bin/main/Main.class
+0
-0
bin/models/Airport.class
bin/models/Airport.class
+0
-0
bin/models/BoardingPass.class
bin/models/BoardingPass.class
+0
-0
bin/services/AirportService.class
bin/services/AirportService.class
+0
-0
src/main/Main.java
src/main/Main.java
+7
-2
src/models/Airport.java
src/models/Airport.java
+1
-5
src/models/BoardingPass.java
src/models/BoardingPass.java
+30
-4
src/services/AirportService.java
src/services/AirportService.java
+5
-5
No files found.
bin/main/Main.class
View file @
852d4779
No preview for this file type
bin/models/Airport.class
View file @
852d4779
No preview for this file type
bin/models/BoardingPass.class
View file @
852d4779
No preview for this file type
bin/services/AirportService.class
View file @
852d4779
No preview for this file type
src/main/Main.java
View file @
852d4779
...
...
@@ -8,6 +8,7 @@ import enums.Nationality;
import
models.Airport
;
import
models.BoardingPass
;
import
models.Passenger
;
import
models.VipPassenger
;
import
services.AirportService
;
public
class
Main
{
...
...
@@ -21,10 +22,14 @@ public class Main {
System
.
out
.
println
();
Passenger
p
=
new
Passenger
(
"Name"
,
"Surname"
,
"1234"
,
Nationality
.
ESTONIAN
,
IdenType
.
IDCARD
,
true
,
"NO"
);
AirportService
.
allPassenger
.
add
(
p
);
BoardingPass
b
=
new
BoardingPass
(
p
);
System
.
out
.
println
(
b
);
VipPassenger
vip
=
new
VipPassenger
(
"Ieva"
,
"Bekmane"
,
"123"
,
Nationality
.
LATVIAN
,
IdenType
.
PASSPORT
,
true
,
"No"
,
"123412"
);
AirportService
.
allPassenger
.
add
(
vip
);
BoardingPass
b2
=
new
BoardingPass
(
vip
);
System
.
out
.
println
(
b2
);
System
.
out
.
println
(
vip
);
Airport
a
=
new
Airport
(
10000
,
AirportName
.
BARSELONA
);
System
.
out
.
println
(
a
);
}
...
...
src/models/Airport.java
View file @
852d4779
...
...
@@ -42,10 +42,6 @@ public class Airport implements INumberGenerator{
}
@Override
public
String
toString
()
{
return
"Airport [airportNr
=
"
+
airportNr
+
", capacity
=
"
+
capacity
+
", airportName
=
"
+
airportName
+
"]"
;
return
"Airport [airportNr
:
"
+
airportNr
+
", capacity
:
"
+
capacity
+
", airportName
:
"
+
airportName
+
"]"
;
}
}
src/models/BoardingPass.java
View file @
852d4779
package
models
;
import
java.util.Random
;
import
ifaces.INumberGenerator
;
import
services.AirportService
;
public
class
BoardingPass
implements
INumberGenerator
{
private
String
boardingPassNr
;
...
...
@@ -26,20 +29,43 @@ public class BoardingPass implements INumberGenerator{
public
BoardingPass
(
Passenger
passenger
)
{
this
.
passenger
=
passenger
;
generateNr
();
generateGroupByPriority
();
generateSeatByPriority
();
}
public
void
generateGroupByPriority
()
{
Random
rand
=
new
Random
();
for
(
int
i
=
0
;
i
<
AirportService
.
allPassenger
.
size
();
i
++)
{
Passenger
tempPass
=
AirportService
.
allPassenger
.
get
(
i
);
if
(
tempPass
instanceof
VipPassenger
)
this
.
group
=
1
;
else
this
.
group
=
(
short
)
(
rand
.
nextInt
(
5
-
2
)
+
2
);
}
}
public
void
generateSeatByPriority
()
{
Random
rand
=
new
Random
();
char
[]
rows
=
{
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
};
for
(
int
i
=
0
;
i
<
AirportService
.
allPassenger
.
size
();
i
++)
{
Passenger
tempPass
=
AirportService
.
allPassenger
.
get
(
i
);
if
(
tempPass
instanceof
VipPassenger
)
{
char
row
=
rows
[
rand
.
nextInt
(
6
-
1
)
+
1
];
short
seat
=
(
short
)
(
rand
.
nextInt
(
3
-
1
)
+
1
);
this
.
seat
=
new
Seat
(
row
,
seat
);
}
else
{
char
row
=
rows
[
rand
.
nextInt
(
6
-
1
)
+
1
];
short
seat
=
(
short
)
(
rand
.
nextInt
(
200
-
3
)
+
3
);
this
.
seat
=
new
Seat
(
row
,
seat
);
}
}
}
@Override
public
void
generateNr
()
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
passenger
.
getName
().
charAt
(
0
));
sb
.
append
(
passenger
.
getSurname
().
charAt
(
0
));
sb
.
append
(
seat
);
sb
.
append
(
group
);
sb
.
append
(
this
.
seat
);
sb
.
append
(
this
.
group
);
this
.
boardingPassNr
=
sb
.
toString
();
}
@Override
...
...
src/services/AirportService.java
View file @
852d4779
...
...
@@ -13,9 +13,9 @@ import models.Passenger;
import
models.VipPassenger
;
public
class
AirportService
{
p
rivate
ArrayList
<
Passenger
>
allPassenger
=
new
ArrayList
<
Passenger
>();
p
rivate
ArrayList
<
BoardingPass
>
allBoardingPasses
=
new
ArrayList
<
BoardingPass
>();
p
rivate
ArrayList
<
Airport
>
allAirports
=
new
ArrayList
<
Airport
>();
p
ublic
static
ArrayList
<
Passenger
>
allPassenger
=
new
ArrayList
<
Passenger
>();
p
ublic
static
ArrayList
<
BoardingPass
>
allBoardingPasses
=
new
ArrayList
<
BoardingPass
>();
p
ublic
static
ArrayList
<
Airport
>
allAirports
=
new
ArrayList
<
Airport
>();
public
AirportService
()
{
...
...
@@ -59,8 +59,8 @@ public class AirportService {
else
{
for
(
AirportName
names
:
AirportName
.
values
())
{
if
(
airportName
==
names
&&
capacity
>
0
)
{
Airport
newA
=
new
Airport
(
capacity
,
airportName
);
allAirports
.
add
(
newA
);
//
Airport newA = new Airport(capacity, airportName);
//
allAirports.add(newA);
return
true
;
}
}
...
...
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