All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class JBMSTours.serializabletypes.CustomerFlight

java.lang.Object
   |
   +----JBMSTours.serializabletypes.CustomerFlight

public class CustomerFlight
extends Object
implements Serializable
Look at the Source.

A CustomerFlight is A FlightObject wrapped in specific date, booking, and customer information. It contains a Flight object as a field (which can be Flight, OneStopFlight, or TransferFlight).


Variable Index

 o arriveCity
 o arriveCity_id
 o departCity
 o departCity_id
 o fixedRate
 o level
 o numberSeats
 o totalCost

Constructor Index

 o CustomerFlight(Date, City, City, int, short, int)
Constructs a customer flight object.

Method Index

 o bookFlight(Connection, int)
Books the flight.
 o checkRate(Connection)
Checks the rate of the currently proposed flight.
 o checkTotalCost(Connection)
Checks the total of the currently proposed flight (rate * number of seats).
 o equals(Object)
Returns true if the two objects are equal.
 o getArrivalDate(Connection)
Date customers actually arrive in city (for long flights).
 o getArriveCity(Connection)
Getter for the city where the flight arrives.
 o getDepartCity(Connection)
Getter for the city where the flight departs from.
 o getFlight()
Gets the Flight ID of the Flight.
 o getFlightObject()
Gets the Flight object (a field).
 o getInfo(Connection)
Prints detailed information about the CustomerFlight.
 o getTravelDate()
Gets the date of travel for the flight (date of departure).
 o prepareStatements(Connection)
Prepares all the PreparedStatements for this class.
 o proposeFlight(Connection, BigDecimal)
Proposes a flight for the group.
 o proposeFlight(Connection, BigDecimal, short)
Proposes a flight for the group.
 o toString()
Returns a string value for the CustomerFlight.
 o toString(Connection)
Returns a string value for the CustomerFlight.

Variables

 o departCity
 public transient City departCity
 o departCity_id
 public int departCity_id
 o arriveCity
 public transient City arriveCity
 o arriveCity_id
 public int arriveCity_id
 o numberSeats
 public int numberSeats
 o fixedRate
 public BigDecimal fixedRate
 o totalCost
 public BigDecimal totalCost
 o level
 public short level

Constructors

 o CustomerFlight
 public CustomerFlight(Date travel,
                       City city1,
                       City city2,
                       int num,
                       short alevel,
                       int gid)
Constructs a customer flight object. Initializes the date of travel, the city of origin, the destination city, the number of seats needed, and the level of travel. To add the actual Flight object to CustomerFlight, use the proposeFlight method. The bookFlight method adds the rate information.

Parameters:
travel - Date of travel
city1 - City of origin
city2 - City of destination
num - Number of seats needed
The - level of the tour. See the static variables in Tour.java.

Methods

 o checkRate
 public BigDecimal checkRate(Connection conn) throws SQLException
Checks the rate of the currently proposed flight. Does not fix the rate. If rate is already fixed, returns that value.

Parameters:
conn - Connection to the database.
Throws: SQLException
Thrown if there is a SQL error.
 o checkTotalCost
 public BigDecimal checkTotalCost(Connection conn) throws SQLException
Checks the total of the currently proposed flight (rate * number of seats). Does not fix the rate. If rate is already fixed, returns that value.

Parameters:
conn - Connection to the database.
Throws: SQLException
Thrown if there is a SQL error.
 o proposeFlight
 public BigDecimal proposeFlight(Connection conn,
                                 BigDecimal availableFunds) throws SQLException, AvailabilityException, BudgetException
Proposes a flight for the group. Returns true if successfully proposed a flight.

Parameters:
conn - Connection to db.
availableFunds - the amount of money the group has left to spend
Returns:
true if successfully proposed flight.
Throws: SQLException
Thrown if there is a SQL error.
Throws: BudgetException
Thrown if the flight is out of the customer's budget.
Throws: AvailabilityException
Thrown if the flight is not available.
 o proposeFlight
 public BigDecimal proposeFlight(Connection conn,
                                 BigDecimal availableFunds,
                                 short templevel) throws SQLException, AvailabilityException, BudgetException
Proposes a flight for the group. Returns true if successfully proposed a flight. Allows you to override level.

Parameters:
conn - Connection to db.
availableFunds - the amount of money the group has left to spend
Returns:
true if successfully proposed flight.
Throws: SQLException
Thrown if there is a SQL error.
Throws: BudgetException
Thrown if the flight is out of the customer's budget.
Throws: AvailabilityException
Thrown if the flight is not available.
 o bookFlight
 public BigDecimal bookFlight(Connection conn,
                              int gid) throws SQLException
Books the flight. --Updates the FlightBookings and the FlightAvailability tables.

Parameters:
conn - Connection to db.
gid - group_id.
Returns:
the total cost of the flights for the group
Throws: SQLException
Thrown if there is a SQL error.
 o getFlight
 public String getFlight()
Gets the Flight ID of the Flight.

Returns:
String The flight_id
 o getFlightObject
 public Flight getFlightObject()
Gets the Flight object (a field).

Returns:
The flight (a Flight object)
See Also:
Flight, OneStopFlight, TransferFlight
 o getTravelDate
 public Date getTravelDate()
Gets the date of travel for the flight (date of departure).

Returns:
Date Date flight departs.
 o getArrivalDate
 public Date getArrivalDate(Connection conn) throws SQLException
Date customers actually arrive in city (for long flights). If the flight arrives after 4 a.m., no hotel stay needed until date of actual arrival, so therefore this method returns the actual date that they arrive. But if the flight arrives before 4 a.m, return the date before the actual arrival date because they will need a hotel stay for the remainder of the "night". Used by HotelStay.

Parameters:
conn - A connection to the database.
Throws: SQLException
thrown on database access failure
See Also:
HotelStay
 o toString
 public String toString(Connection conn) throws SQLException
Returns a string value for the CustomerFlight.

Parameters:
conn - Conenction to the database.
Returns:
String A string value for the CustomerFlight.
Throws: SQLException
In case of a database error.
 o toString
 public String toString()
Returns a string value for the CustomerFlight.

Returns:
String A string value for the CustomerFlight.
Overrides:
toString in class Object
 o getInfo
 public String getInfo(Connection conn) throws SQLException
Prints detailed information about the CustomerFlight.

Parameters:
conn - A connection to the database.
Returns:
String object information about the CustomerFlight
Throws: SQLException
in case of a database error.
 o getArriveCity
 public City getArriveCity(Connection conn) throws SQLException
Getter for the city where the flight arrives.

Parameters:
conn - A connection to the database.
Returns:
City City where the flight arrives.
Throws: SQLException
in case of a database error
 o getDepartCity
 public City getDepartCity(Connection conn) throws SQLException
Getter for the city where the flight departs from.

Parameters:
conn - A connection to the database.
Returns:
City City where the flight departs from.
Throws: SQLException
in case of a database error
 o prepareStatements
 public boolean prepareStatements(Connection conn) throws SQLException
Prepares all the PreparedStatements for this class.

Parameters:
conn - a connection to the database.
Returns:
boolean if statements are prepared without error
Throws: SQLException
If there is an SQL error
 o equals
 public boolean equals(Object o)
Returns true if the two objects are equal.

Overrides:
equals in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index