Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
project-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
Amirhosein Rajabpour
project-Lab7
Commits
70bf88cf
Commit
70bf88cf
authored
Apr 28, 2019
by
Amirhosein Rajabpour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
third commit (documentations added)
parent
9ac7597c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
184 additions
and
15 deletions
+184
-15
7.pdf
7.pdf
+0
-0
Airplane.java
src/com/TicketManagement/Airplane.java
+26
-1
Customer.java
src/com/TicketManagement/Customer.java
+25
-6
Flight.java
src/com/TicketManagement/Flight.java
+57
-6
Seat.java
src/com/TicketManagement/Seat.java
+22
-0
Ticket.java
src/com/TicketManagement/Ticket.java
+29
-0
TicketManagement.java
src/com/TicketManagement/TicketManagement.java
+25
-2
No files found.
7.pdf
0 → 100644
View file @
70bf88cf
File added
src/com/TicketManagement/Airplane.java
View file @
70bf88cf
package
com
.
TicketManagement
;
package
com
.
TicketManagement
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
/**
* @author Amirhosein Rajabpour
* this class is airplane class and airplane are collaborated
* with seat and flight classes directly
*/
public
class
Airplane
{
public
class
Airplane
{
private
Seat
seat
;
private
Seat
seat
;
private
String
airplaneagency
;
private
String
airplaneagency
;
...
@@ -13,14 +17,35 @@ public class Airplane {
...
@@ -13,14 +17,35 @@ public class Airplane {
this
.
model
=
model
;
this
.
model
=
model
;
}
}
/**
* arraylist of the reserved seats in an airplane
*/
ArrayList
<
Seat
>
seats
=
new
ArrayList
<>();
ArrayList
<
Seat
>
seats
=
new
ArrayList
<>();
/**
*
* @return all reserved seats in airplane
*/
public
ArrayList
<
Seat
>
getSeats
()
{
return
seats
;
}
public
ArrayList
<
Seat
>
getSeats
()
{
return
seats
;
}
/**
*
* @return the model of aircraft
*/
public
String
getModel
(){
return
model
;}
public
String
getModel
(){
return
model
;}
/**
*
* @return the airplane's agency (or airline)
*/
public
String
getAirplaneagency
()
{
return
airplaneagency
;
}
public
String
getAirplaneagency
()
{
return
airplaneagency
;
}
/**
* this methode takes a seat and checks if that seat is already occupied or not
* and if the seat is free it reserves the seat otherwise nothing
* @param seat is the seat which should be checked
* @return if the seat is free it returns false and if the seat is occupied it returns true
*/
public
boolean
reserveSeat
(
Seat
seat
)
{
public
boolean
reserveSeat
(
Seat
seat
)
{
if
(
seats
.
contains
(
seat
))
if
(
seats
.
contains
(
seat
))
...
...
src/com/TicketManagement/Customer.java
View file @
70bf88cf
package
com
.
TicketManagement
;
package
com
.
TicketManagement
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
/**
* @author Amirhosein Rajabpour
* this class is our passenger's class
*/
public
class
Customer
{
public
class
Customer
{
private
String
name
,
lastname
;
private
String
name
,
lastname
;
private
int
ID
;
private
int
ID
;
...
@@ -13,15 +16,31 @@ public class Customer {
...
@@ -13,15 +16,31 @@ public class Customer {
this
.
lastname
=
lastname
;
this
.
lastname
=
lastname
;
}
}
/**
*
* @return our customer's ID
*/
public
int
getID
()
{
return
ID
;
}
public
int
getID
()
{
return
ID
;
}
/**
*
* @returnour customer's name
*/
public
String
getName
()
{
return
name
;
}
public
String
getName
()
{
return
name
;
}
/**
*
* @returnour customer's family name
*/
public
String
getLastname
()
{
return
lastname
;
}
public
String
getLastname
()
{
return
lastname
;
}
public
void
addTicket
(
Ticket
t
){
tickets
.
add
(
t
);
/**
t
.
getFlight
().
getAirplane
().
reserveSeat
(
t
.
getSeat
);
*
}
* @param t which is a ticket that our customer wants to buy
* customer buy the ticket ad the seat will be booked
*/
public
void
buyTicket
(
Ticket
t
){
tickets
.
add
(
t
);
t
.
getFlight
().
getAirplane
().
reserveSeat
(
t
.
getSeat
());
}
}
}
src/com/TicketManagement/Flight.java
View file @
70bf88cf
package
com
.
TicketManagement
;
package
com
.
TicketManagement
;
import
java.util.Date
;
import
java.util.Date
;
/**
* @author Amirhosein Rajabpour
*
* flight class represents fields related to flights
*/
public
class
Flight
{
public
class
Flight
{
private
Date
date
;
private
Date
date
;
private
String
destination
;
private
String
destination
;
...
@@ -12,35 +16,82 @@ public class Flight {
...
@@ -12,35 +16,82 @@ public class Flight {
private
String
model
;
private
String
model
;
public
Flight
(
Date
date
,
int
flightNumber
,
String
destination
,
String
source
,
Airplane
airplane
){
public
Flight
(
Date
date
,
int
flightNumber
,
String
destination
,
String
source
,
Airplane
airplane
){
this
.
date
=
date
;
this
.
date
=
date
;
this
.
source
=
source
;
this
.
source
=
source
;
this
.
airplane
=
airplane
;
this
.
airplane
=
airplane
;
this
.
destination
=
destination
;
this
.
destination
=
destination
;
this
.
flightNumber
=
flightNumber
;
this
.
flightNumber
=
flightNumber
;
this
.
company
=
airplane
.
getAirplaneagency
();
this
.
company
=
airplane
.
getAirplaneagency
();
this
.
model
=
airplane
.
getModel
();
this
.
model
=
airplane
.
getModel
();
}
}
/**
*
* @return flight number
*/
public
int
getFlightNumber
()
{
public
int
getFlightNumber
()
{
return
flightNumber
;
return
flightNumber
;
}
}
/**
*
* @return source of the flight
*/
public
String
getSource
()
{
public
String
getSource
()
{
return
source
;
return
source
;
}
}
/**
*
* @return object of airplane
*/
public
Airplane
getAirplane
()
{
public
Airplane
getAirplane
()
{
return
airplane
;
return
airplane
;
}
}
/**
*
* @return date of the flight
*/
public
Date
getDate
()
{
public
Date
getDate
()
{
return
date
;
return
date
;
}
}
/**
*
* @return destination of the flight
*/
public
String
getDestination
()
{
public
String
getDestination
()
{
return
destination
;
return
destination
;
}
}
/**
*
* @return airplain's company (airline)
*/
public
String
getCompany
(){
return
company
;}
public
String
getCompany
(){
return
company
;}
/**
*
* @return model of the Aircraft
*/
public
String
getModel
(){
return
model
;}
/**
*
* @param f which is a flight object
* shows details of a specific flight
*/
public
void
displayFlight
(
Flight
f
){
System
.
out
.
println
(
f
.
getDate
());
System
.
out
.
println
(
f
.
getDestination
());
System
.
out
.
println
(
f
.
getCompany
());
System
.
out
.
println
(
f
.
getModel
());
System
.
out
.
println
(
f
.
getFlightNumber
());
}
}
}
src/com/TicketManagement/Seat.java
View file @
70bf88cf
package
com
.
TicketManagement
;
package
com
.
TicketManagement
;
/**
* @author Amirhosein Rajabpour
*
* this class indicates a seat and it's features for us
*/
public
class
Seat
{
public
class
Seat
{
private
int
ID
;
private
int
ID
;
private
String
Type
;
private
String
Type
;
...
@@ -10,15 +15,32 @@ public class Seat {
...
@@ -10,15 +15,32 @@ public class Seat {
this
.
ID
=
ID
;
this
.
ID
=
ID
;
}
}
/**
*
* @return seat number
*/
public
int
getID
()
{
public
int
getID
()
{
return
ID
;
return
ID
;
}
}
/**
*
* @return type of the seat which can be business class, first class or economic class
*/
public
String
getType
()
{
public
String
getType
()
{
return
Type
;
return
Type
;
}
}
/**
*
* @return the ID of the user who has reserved this seat already
*/
public
int
getUserID
(){
return
userID
;}
public
int
getUserID
(){
return
userID
;}
/**
*
* @param u is our user ID who booked the seat and set this ID
*/
public
void
setUser
(
int
u
)
{
userID
=
u
;
}
public
void
setUser
(
int
u
)
{
userID
=
u
;
}
}
}
src/com/TicketManagement/Ticket.java
View file @
70bf88cf
package
com
.
TicketManagement
;
package
com
.
TicketManagement
;
/**
* @author Amirhosein Rajabpour
*
* this class is for simulating a ticket and some related parameters
*/
public
class
Ticket
{
public
class
Ticket
{
private
int
seatnumber
;
private
int
seatnumber
;
private
int
flightnumber
;
private
int
flightnumber
;
...
@@ -15,23 +20,47 @@ public class Ticket {
...
@@ -15,23 +20,47 @@ public class Ticket {
this
.
food
=
food
;
this
.
food
=
food
;
}
}
/**
* each passenger can have a specific amount of luggage
* @return the passenger's luggage weight
*/
public
int
getLuggageWeight
()
{
public
int
getLuggageWeight
()
{
return
LuggageWeight
;
return
LuggageWeight
;
}
}
/**
* each passenger can have a meal
* @return passenger's food
*/
public
String
getFood
()
{
public
String
getFood
()
{
return
food
;
return
food
;
}
}
/**
*
* @return passenger's flight number ( which is obviously mentioned in the ticket)
*/
public
int
getFlightnumber
()
{
public
int
getFlightnumber
()
{
return
flightnumber
;
return
flightnumber
;
}
}
/**
*
* @return passenger's seat number
*/
public
int
getSeatnumber
()
{
public
int
getSeatnumber
()
{
return
seatnumber
;
return
seatnumber
;
}
}
/**
*
* @return the object of passenger's flight
*/
public
Flight
getFlight
()
{
return
flight
;}
public
Flight
getFlight
()
{
return
flight
;}
/**
*
* @return the object of passenger's seat
*/
public
Seat
getSeat
(){
return
seat
;}
public
Seat
getSeat
(){
return
seat
;}
}
}
src/com/TicketManagement/TicketManagement.java
View file @
70bf88cf
package
com
.
TicketManagement
;
package
com
.
TicketManagement
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
/**
* @author Amirhosein Rajabpour
*
* this class manages the booking flight system
*/
public
class
TicketManagement
{
public
class
TicketManagement
{
private
ArrayList
<
Flight
>
flights
=
new
ArrayList
<
Flight
>();
/**
* an arraylist out of Flight objects which aggregates all flights
*/
private
ArrayList
<
Flight
>
flights
=
new
ArrayList
<
Flight
>();
/**
*
* @return all flights
*/
public
ArrayList
<
Flight
>
getFlights
()
{
public
ArrayList
<
Flight
>
getFlights
()
{
return
flights
;
return
flights
;
}
}
/**
*
* @param flight
* takes an specific flight object and remove it from our flight array list
*/
public
void
removeFlight
(
Flight
flight
){
flights
.
remove
(
flight
);}
public
void
removeFlight
(
Flight
flight
){
flights
.
remove
(
flight
);}
/**
*
* @param flight
* takes a flight and add it to flight array list
*/
public
void
addFlight
(
Flight
flight
){
public
void
addFlight
(
Flight
flight
){
flights
.
add
(
flight
);
flights
.
add
(
flight
);
}
}
...
...
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