reservation.system
Class Person

java.lang.Object
  extended byreservation.system.Person
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
Profile

public class Person
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

This class hold person structure. This object could be asserted in the PersonList.

Author:
Texier Mathieu and Frederic Bidon
See Also:
Serialized Form

Constructor Summary
(package private) Person()
          Construct an empty person
(package private) Person(java.lang.String personName, Flight flight, int bookingNumber, Pos pos)
          Construct a Person named personName booked on the flight the seat pos and has the booking number : bookingNumber.
 
Method Summary
 void _check()
          Verify invariants : - regex ^[A-Z][a-z]* - seat < dimension of the flight and > 0
protected  java.lang.Object clone()
          Creates and returns a copy of this object.
 boolean equals(java.lang.Object anObject)
          Overide equals
 int getBookingNumber()
          Return the booking number
 Flight getFlight()
          Return the flight
 java.lang.String getPersonName()
          Return the name of the person
 Pos getPos()
          Return the position of the seat
(package private)  void setBookingNumber(int bookingNumber)
          Set the booking number
(package private)  void setFlight(Flight flight)
          Set the flight
(package private)  void setPersonName(java.lang.String personName)
          Set the name of the person
(package private)  void setPos(Pos pos)
          Set the position
 java.lang.String toString()
          Returns a string representation of this Person object.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Person

Person()
Construct an empty person


Person

Person(java.lang.String personName,
       Flight flight,
       int bookingNumber,
       Pos pos)
 throws java.lang.Exception
Construct a Person named personName booked on the flight the seat pos and has the booking number : bookingNumber.

Parameters:
personName - Name of the person.
flight - Flight on witch the person has booked.
bookingNumber - used to Identify a group of person
pos - The position of the seat on the flight
Throws:
java.lang.Exception - if the invariant _check() is violated
Method Detail

setPersonName

void setPersonName(java.lang.String personName)
             throws java.lang.Exception
Set the name of the person

Parameters:
personName - name of the person
Throws:
java.lang.Exception - if the invariant _check() is violated

setFlight

void setFlight(Flight flight)
         throws java.lang.Exception
Set the flight

Parameters:
flight - Flight on witch the person has booked.
Throws:
java.lang.Exception - if the invariant _check() is violated

setBookingNumber

void setBookingNumber(int bookingNumber)
                throws java.lang.Exception
Set the booking number

Parameters:
bookingNumber - the booking number
Throws:
java.lang.Exception - if the invariant _check() is violated

setPos

void setPos(Pos pos)
      throws java.lang.Exception
Set the position

Parameters:
pos - The position of the seat on the flight
Throws:
java.lang.Exception - if the invariant _check() is violated

getPersonName

public final java.lang.String getPersonName()
                                     throws java.lang.Exception
Return the name of the person

Returns:
the name of the person
Throws:
java.lang.Exception - if the invariant _check() is violated

getFlight

public final Flight getFlight()
                       throws java.lang.Exception
Return the flight

Returns:
the flight on witch the person has booked.
Throws:
java.lang.Exception - if the invariant _check() is violated

getBookingNumber

public final int getBookingNumber()
                           throws java.lang.Exception
Return the booking number

Returns:
the booking number
Throws:
java.lang.Exception - if the invariant _check() is violated

getPos

public final Pos getPos()
                 throws java.lang.Exception
Return the position of the seat

Returns:
pos the position of the seat in the Flight
Throws:
java.lang.Exception - if the invariant _check() is violated

toString

public java.lang.String toString()
Returns a string representation of this Person object. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null

Returns:
a string representation of this Person object.

equals

public boolean equals(java.lang.Object anObject)
Overide equals

Parameters:
anObject - anObject - the reference object with which to compare
Returns:
true if this object is the same as the obj argument or match a Profile object; false otherwise

_check

public void _check()
            throws java.lang.Exception,
                   java.lang.NullPointerException
Verify invariants :
     - regex ^[A-Z][a-z]*
     - seat < dimension of the flight and > 0
     

Throws:
java.lang.NullPointerException - if pos or name is null
java.lang.Exception - if the invariant is violated

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
Creates and returns a copy of this object.

Returns:
a copy of this Person object
Throws:
java.lang.CloneNotSupportedException - if the object's class does not support the Cloneable interface.