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
9731082
lab7
Commits
499109b3
Commit
499109b3
authored
May 05, 2019
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ehtemalan akharish
parent
60ec98b3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
99 additions
and
28 deletions
+99
-28
Airplane.java
src/Airplane.java
+13
-1
Customer.java
src/Customer.java
+20
-1
Flight.java
src/Flight.java
+36
-9
Seat.java
src/Seat.java
+5
-5
System.java
src/System.java
+16
-3
Ticket.java
src/Ticket.java
+9
-9
No files found.
src/Airplane.java
View file @
499109b3
...
@@ -8,9 +8,14 @@ public class Airplane {
...
@@ -8,9 +8,14 @@ public class Airplane {
public
Airplane
(
String
type
,
ArrayList
<
Seat
>
seats
){
public
Airplane
(
String
type
,
ArrayList
<
Seat
>
seats
){
this
.
type
=
type
;
this
.
type
=
type
;
this
.
freeSeats
=
seats
;
this
.
seats
=
seats
;
this
.
seats
=
seats
;
}
}
public
String
getType
()
{
return
type
;
}
public
ArrayList
<
Seat
>
getSeats
(){
public
ArrayList
<
Seat
>
getSeats
(){
return
seats
;
return
seats
;
}
}
...
@@ -19,7 +24,14 @@ public class Airplane {
...
@@ -19,7 +24,14 @@ public class Airplane {
return
freeSeats
;
return
freeSeats
;
}
}
public
void
reserveSeat
(
Seat
seat
){
public
void
reserveSeat
(
Seat
seat
,
Customer
customer
){
for
(
Seat
s
:
seats
)
{
if
(
s
==
seat
)
{
s
.
setCustomer
(
customer
);
}
}
this
.
freeSeats
.
remove
(
seat
);
}
}
...
...
src/Customer.java
View file @
499109b3
import
java.util.ArrayList
;
public
class
Customer
{
public
class
Customer
{
private
String
name
;
private
String
name
;
private
String
lastname
;
private
String
lastname
;
private
int
ID
;
private
int
ID
;
ArrayList
<
Ticket
>
tickets
=
null
;
public
Customer
(
String
name
,
String
lastname
,
int
ID
){
public
Customer
(
String
name
,
String
lastname
,
int
ID
){
this
.
name
=
name
;
this
.
name
=
name
;
...
@@ -10,9 +13,25 @@ public class Customer {
...
@@ -10,9 +13,25 @@ public class Customer {
this
.
ID
=
ID
;
this
.
ID
=
ID
;
}
}
public
void
reserve
(
Flight
flight
,
Seat
seat
,
Boolean
hasFood
,
int
weight
){
public
String
getName
()
{
return
name
;
}
public
String
getLastname
(){
return
lastname
;
}
public
int
getID
()
{
return
ID
;
}
}
public
ArrayList
<
Ticket
>
getTickets
()
{
return
tickets
;
}
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
);
}
}
}
src/Flight.java
View file @
499109b3
import
java.util.ArrayList
;
public
class
Flight
{
public
class
Flight
{
private
Airplane
airplane
;
private
Airplane
airplane
;
private
int
ID
;
private
String
source
;
private
String
source
;
private
String
dest
;
private
String
dest
;
private
String
company
;
private
String
company
;
private
int
no
;
private
String
type
;
private
int
date
;
public
Flight
(
int
ID
,
String
source
,
String
dest
,
String
company
){
public
Flight
(
Airplane
airplane
,
String
source
,
String
dest
,
String
company
,
String
type
,
int
no
,
int
date
){
this
.
ID
=
ID
;
this
.
airplane
=
airplane
;
this
.
source
=
source
;
this
.
source
=
source
;
this
.
dest
=
dest
;
this
.
dest
=
dest
;
this
.
company
=
company
;
this
.
company
=
company
;
this
.
type
=
type
;
this
.
no
=
no
;
this
.
date
=
date
;
}
}
public
int
getID
(){
public
Airplane
getAirplane
(){
return
getID
()
;
return
airplane
;
}
}
public
String
getSource
(){
public
String
getSource
(){
...
@@ -26,13 +33,33 @@ public class Flight {
...
@@ -26,13 +33,33 @@ public class Flight {
return
dest
;
return
dest
;
}
}
public
Airplane
getAirplane
(){
return
airplane
;
}
public
String
getCompany
(){
public
String
getCompany
(){
return
company
;
return
company
;
}
}
public
String
getType
(){
return
type
;
}
public
int
getNo
(){
return
no
;
}
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
,
Customer
customer
)
{
this
.
airplane
.
reserveSeat
(
seat
,
customer
);
}
}
}
src/Seat.java
View file @
499109b3
...
@@ -2,10 +2,10 @@ public class Seat {
...
@@ -2,10 +2,10 @@ public class Seat {
private
String
type
;
private
String
type
;
private
Customer
customer
;
private
Customer
customer
;
private
int
n
um
;
private
int
n
o
;
public
Seat
(
int
n
um
,
String
type
){
public
Seat
(
int
n
o
,
String
type
){
this
.
n
um
=
num
;
this
.
n
o
=
no
;
this
.
type
=
type
;
this
.
type
=
type
;
}
}
...
@@ -21,8 +21,8 @@ public class Seat {
...
@@ -21,8 +21,8 @@ public class Seat {
return
type
;
return
type
;
}
}
public
int
getN
um
()
{
public
int
getN
o
()
{
return
n
um
;
return
n
o
;
}
}
}
}
src/System.java
View file @
499109b3
...
@@ -5,16 +5,29 @@ public class System {
...
@@ -5,16 +5,29 @@ public class System {
private
ArrayList
<
Flight
>
flights
;
private
ArrayList
<
Flight
>
flights
;
public
System
(){
public
System
(
ArrayList
<
Flight
>
flights
){
this
.
flights
=
flights
;
}
}
public
void
addFlight
(
Flight
flight
){
public
void
addFlight
(
Flight
flight
){
this
.
flights
.
add
()
;
this
.
flights
.
add
(
flight
)
;
}
}
public
void
removeFlight
(
Flight
flight
){
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
,
Customer
customer
)
{
for
(
Flight
f
:
flights
)
{
if
(
f
==
flight
)
{
f
.
reserve
(
seat
,
customer
);
}
}
}
}
}
src/Ticket.java
View file @
499109b3
public
class
Ticket
{
public
class
Ticket
{
private
int
seatN
um
;
private
int
seatN
o
;
private
int
flightN
um
;
private
int
flightN
o
;
private
int
luggageWeight
;
private
int
luggageWeight
;
private
Boolean
foodStatus
;
private
Boolean
foodStatus
;
public
Ticket
(
int
seatN
um
,
int
flightNum
,
int
luggageWeight
,
boolean
foodStatus
){
public
Ticket
(
int
seatN
o
,
int
flightNum
,
int
luggageWeight
,
boolean
foodStatus
){
this
.
seatN
um
=
seatNum
;
this
.
seatN
o
=
seatNo
;
this
.
flightN
um
=
flightNum
;
this
.
flightN
o
=
flightNum
;
this
.
luggageWeight
=
luggageWeight
;
this
.
luggageWeight
=
luggageWeight
;
this
.
foodStatus
=
foodStatus
;
this
.
foodStatus
=
foodStatus
;
}
}
public
int
getSeatN
um
(){
public
int
getSeatN
o
(){
return
seatN
um
;
return
seatN
o
;
}
}
public
int
getFlightN
um
(){
public
int
getFlightN
o
(){
return
flightN
um
;
return
flightN
o
;
}
}
public
int
getLuggageWeight
(){
public
int
getLuggageWeight
(){
...
...
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