Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
Lab7
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
9731087
Lab7
Commits
6dbfdcec
Commit
6dbfdcec
authored
May 05, 2019
by
9731087
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
b1777934
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
7 deletions
+53
-7
Airplane.java
src/Airplane.java
+12
-1
Flight.java
src/Flight.java
+15
-1
Passenger.java
src/Passenger.java
+10
-2
SystemManagement.java
src/SystemManagement.java
+16
-3
No files found.
src/Airplane.java
View file @
6dbfdcec
...
...
@@ -8,6 +8,7 @@ public class Airplane {
public
Airplane
(
ArrayList
<
Seat
>
seats
,
String
type
)
{
this
.
seats
=
seats
;
this
.
freeSeats
=
seats
;
this
.
type
=
type
;
}
...
...
@@ -19,7 +20,17 @@ public class Airplane {
return
seats
;
}
public
void
reserve
(
Seat
seat
)
{
public
String
getType
()
{
return
type
;
}
public
void
reserve
(
Seat
seat
,
Passenger
passenger
)
{
for
(
Seat
s
:
seats
)
{
if
(
s
==
seat
)
{
s
.
setPassenger
(
passenger
);
}
}
this
.
freeSeats
.
remove
(
seat
);
}
}
src/Flight.java
View file @
6dbfdcec
import
java.util.ArrayList
;
public
class
Flight
{
private
Airplane
airplane
;
...
...
@@ -8,7 +10,7 @@ public class Flight {
private
int
No
;
private
int
date
;
public
Flight
(
Airplane
airplane
,
String
company
,
String
destination
,
String
origin
,
String
type
,
int
No
,
int
date
)
{
public
Flight
(
Airplane
airplane
,
String
company
,
String
destination
,
String
origin
,
String
type
,
int
No
,
int
date
)
{
this
.
airplane
=
airplane
;
this
.
company
=
company
;
this
.
destination
=
destination
;
...
...
@@ -45,4 +47,16 @@ public class Flight {
public
int
getDate
()
{
return
date
;
}
public
ArrayList
<
Seat
>
getFreeSeats
()
{
return
this
.
airplane
.
getFreeSeats
();
}
public
ArrayList
<
Seat
>
getSeats
()
{
return
this
.
airplane
.
getSeats
();
}
public
void
reserve
(
Seat
seat
,
Passenger
passenger
)
{
this
.
airplane
.
reserve
(
seat
,
passenger
);
}
}
src/Passenger.java
View file @
6dbfdcec
import
java.util.ArrayList
;
public
class
Passenger
{
private
String
name
;
private
String
lastName
;
int
ID
;
ArrayList
<
Ticket
>
tickets
=
null
;
public
Passenger
(
String
name
,
String
lastName
,
int
ID
){
public
Passenger
(
String
name
,
String
lastName
,
int
ID
)
{
this
.
name
=
name
;
this
.
lastName
=
lastName
;
this
.
ID
=
ID
;
}
public
void
reserve
(
Flight
flight
,
Seat
seat
,
Boolean
hasFood
,
int
weight
){
public
void
reserve
(
Flight
flight
,
Seat
seat
,
Boolean
hasFood
,
int
weight
)
{
Ticket
ticket
=
new
Ticket
(
seat
.
getNo
(),
flight
.
getNo
(),
weight
,
hasFood
);
this
.
tickets
.
add
(
ticket
);
}
public
ArrayList
<
Ticket
>
getTickets
()
{
return
tickets
;
}
}
src/SystemManagement.java
View file @
6dbfdcec
...
...
@@ -4,8 +4,8 @@ public class SystemManagement {
private
ArrayList
<
Flight
>
flights
;
public
SystemManagement
()
{
public
SystemManagement
(
ArrayList
<
Flight
>
flights
)
{
this
.
flights
=
flights
;
}
public
void
addFlight
(
Flight
flight
)
{
...
...
@@ -13,6 +13,19 @@ public class SystemManagement {
}
public
void
removeFlight
(
Flight
flight
)
{
this
.
flights
.
remove
(
flight
);
this
.
flights
.
remove
(
flight
);
}
public
ArrayList
<
Flight
>
getFlights
()
{
return
flights
;
}
public
void
reserve
(
Flight
flight
,
Seat
seat
,
Passenger
passenger
)
{
for
(
Flight
f
:
flights
)
{
if
(
f
==
flight
)
{
f
.
reserve
(
seat
,
passenger
);
}
}
}
}
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