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
70ce7380
Commit
70ce7380
authored
May 05, 2019
by
9731087
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
probably the last on
parent
6dbfdcec
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
210 additions
and
2 deletions
+210
-2
Airplane.java
src/Airplane.java
+30
-0
Flight.java
src/Flight.java
+65
-0
Passenger.java
src/Passenger.java
+23
-0
Seat.java
src/Seat.java
+30
-1
SystemManagement.java
src/SystemManagement.java
+30
-0
Ticket.java
src/Ticket.java
+32
-1
No files found.
src/Airplane.java
View file @
70ce7380
import
java.util.ArrayList
;
/**
* airplane of the flight
*/
public
class
Airplane
{
private
String
type
;
private
ArrayList
<
Seat
>
seats
;
private
ArrayList
<
Seat
>
freeSeats
;
/**
* constructs an airplane
*
* @param seats
* @param type
*/
public
Airplane
(
ArrayList
<
Seat
>
seats
,
String
type
)
{
this
.
seats
=
seats
;
this
.
freeSeats
=
seats
;
this
.
type
=
type
;
}
/**
* returns free seats
*
* @return
*/
public
ArrayList
<
Seat
>
getFreeSeats
()
{
return
freeSeats
;
}
/**
* returns all of seats
*
* @return
*/
public
ArrayList
<
Seat
>
getSeats
()
{
return
seats
;
}
/**
* returns the type of seat
*
* @return
*/
public
String
getType
()
{
return
type
;
}
/**
* reserves a seat for a passenger on this airplane
*
* @param seat
* @param passenger
*/
public
void
reserve
(
Seat
seat
,
Passenger
passenger
)
{
for
(
Seat
s
:
seats
)
{
...
...
src/Flight.java
View file @
70ce7380
import
java.util.ArrayList
;
/**
* an available flight
*/
public
class
Flight
{
private
Airplane
airplane
;
...
...
@@ -10,6 +13,17 @@ public class Flight {
private
int
No
;
private
int
date
;
/**
* constructs a flight
*
* @param airplane
* @param company
* @param destination
* @param origin
* @param type
* @param No
* @param date
*/
public
Flight
(
Airplane
airplane
,
String
company
,
String
destination
,
String
origin
,
String
type
,
int
No
,
int
date
)
{
this
.
airplane
=
airplane
;
this
.
company
=
company
;
...
...
@@ -20,42 +34,93 @@ public class Flight {
this
.
date
=
date
;
}
/**
* returns type of this flight
*
* @return
*/
public
String
getType
()
{
return
type
;
}
/**
* returns number of this flight
*
* @return
*/
public
int
getNo
()
{
return
No
;
}
/**
* returns airplane of this flight
*
* @return
*/
public
Airplane
getAirplane
()
{
return
airplane
;
}
/**
* returns company of this flight
*
* @return
*/
public
String
getCompany
()
{
return
company
;
}
/**
* returns destination of this flight
*
* @return
*/
public
String
getDestination
()
{
return
destination
;
}
/**
* returns origin of this flight
*
* @return
*/
public
String
getOrigin
()
{
return
origin
;
}
/**
* returns date of this flight
*
* @return
*/
public
int
getDate
()
{
return
date
;
}
/**
* returns free seats on this flight
*
* @return
*/
public
ArrayList
<
Seat
>
getFreeSeats
()
{
return
this
.
airplane
.
getFreeSeats
();
}
/**
* returns total seats of this flight
*
* @return
*/
public
ArrayList
<
Seat
>
getSeats
()
{
return
this
.
airplane
.
getSeats
();
}
/**
* reserves a seat for a passenger
*
* @param seat
* @param passenger
*/
public
void
reserve
(
Seat
seat
,
Passenger
passenger
)
{
this
.
airplane
.
reserve
(
seat
,
passenger
);
}
...
...
src/Passenger.java
View file @
70ce7380
import
java.util.ArrayList
;
/**
* passenger of the flight
*/
public
class
Passenger
{
private
String
name
;
...
...
@@ -7,17 +10,37 @@ public class Passenger {
int
ID
;
ArrayList
<
Ticket
>
tickets
=
null
;
/**
* constructs a passenger
*
* @param name
* @param lastName
* @param ID
*/
public
Passenger
(
String
name
,
String
lastName
,
int
ID
)
{
this
.
name
=
name
;
this
.
lastName
=
lastName
;
this
.
ID
=
ID
;
}
/**
* reserves a ticket for this passenger
*
* @param flight
* @param seat
* @param hasFood
* @param 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
);
}
/**
* returns passenger's tickets
*
* @return
*/
public
ArrayList
<
Ticket
>
getTickets
()
{
return
tickets
;
}
...
...
src/Seat.java
View file @
70ce7380
/**
* seat of the airplane
*/
public
class
Seat
{
private
int
No
;
private
String
type
;
private
Passenger
passenger
;
public
Seat
(
int
No
,
String
type
){
/**
* constructs a seat
*
* @param No
* @param type
*/
public
Seat
(
int
No
,
String
type
)
{
this
.
No
=
No
;
this
.
type
=
type
;
}
/**
* returns seats number
*
* @return
*/
public
int
getNo
()
{
return
No
;
}
/**
* return seats type
*
* @return
*/
public
String
getType
()
{
return
type
;
}
/**
* relates a passenger to this seat
*
* @param passenger
*/
public
void
setPassenger
(
Passenger
passenger
)
{
this
.
passenger
=
passenger
;
}
/**
* returns passenger who reserved this seat
*
* @return
*/
public
Passenger
getPassenger
()
{
return
passenger
;
}
...
...
src/SystemManagement.java
View file @
70ce7380
import
java.util.ArrayList
;
/**
* the manager of all flights
*/
public
class
SystemManagement
{
private
ArrayList
<
Flight
>
flights
;
/**
* constructs a system management
*
* @param flights
*/
public
SystemManagement
(
ArrayList
<
Flight
>
flights
)
{
this
.
flights
=
flights
;
}
/**
* adds a flight to the flight list
*
* @param flight
*/
public
void
addFlight
(
Flight
flight
)
{
this
.
flights
.
add
(
flight
);
}
/**
* removes a flight from the flight list
*
* @param flight
*/
public
void
removeFlight
(
Flight
flight
)
{
this
.
flights
.
remove
(
flight
);
}
/**
* returns all of the flights
*
* @return
*/
public
ArrayList
<
Flight
>
getFlights
()
{
return
flights
;
}
/**
* reserves a seat from a flight for a passenger
*
* @param flight
* @param seat
* @param passenger
*/
public
void
reserve
(
Flight
flight
,
Seat
seat
,
Passenger
passenger
)
{
for
(
Flight
f
:
flights
)
{
...
...
src/Ticket.java
View file @
70ce7380
/**
* reservation ticket
*/
public
class
Ticket
{
private
int
SeatNo
;
...
...
@@ -5,25 +8,53 @@ public class Ticket {
private
int
baggageWeight
;
private
Boolean
foodStatus
;
public
Ticket
(
int
seatNo
,
int
flightNo
,
int
baggageWeight
,
Boolean
foodStatus
){
/**
* constructs a ticket
*
* @param seatNo
* @param flightNo
* @param baggageWeight
* @param foodStatus
*/
public
Ticket
(
int
seatNo
,
int
flightNo
,
int
baggageWeight
,
Boolean
foodStatus
)
{
this
.
SeatNo
=
seatNo
;
this
.
flightNo
=
flightNo
;
this
.
baggageWeight
=
baggageWeight
;
this
.
foodStatus
=
foodStatus
;
}
/**
* returns the food status
*
* @return
*/
public
Boolean
getFoodStatus
()
{
return
foodStatus
;
}
/**
* returns the baggage weight
*
* @return
*/
public
int
getBaggageWeight
()
{
return
baggageWeight
;
}
/**
* returns the flight number
*
* @return
*/
public
int
getFlightNo
()
{
return
flightNo
;
}
/**
* returns the seat nomber
*
* @return
*/
public
int
getSeatNo
()
{
return
SeatNo
;
}
...
...
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