reservation.system
Class Profile

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

public class Profile
extends Person

The overall idea of this class is to provide a method of comparison between a person and an incomplete Person structure. In another way, a class such as Person

 - flight:Flight = aFlight
 - personName:String =  aName
 - bookingNumber: Integer =  aBooking
 - pos: Pos = aSeat
 
equals Profile
 - flight:Flight = aFlight
 - personNameMask:boolean = true
 - bookingNumberMask:boolean = true
 - posMask:boolean = true
 

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

Constructor Summary
Profile()
          Construct an empty profile
 
Method Summary
 void _check()
          Verify invariants : - either the mask is true or the object = null
 boolean bookingNumberIsMask()
          Return true if bookingNumber is masked
 boolean equals(java.lang.Object anObject)
          Overide equals return true if for all fields: person.field. == profile.field || profile.fieldIsMask Where the fields to test are: the name, the flight, the booking number, the seat.
 boolean flightIsMask()
          Return true if flight is masked
 boolean personNameIsMask()
          Return true if personName is masked
 boolean posIsMask()
          Return true if pos is masked
 void setBookingNumber(int bookingNumber)
          Set the booking number and unmask the value
 void setFlight(Flight flight)
          Set the flight and unmask the value
 void setPersonName(java.lang.String personName)
          Set the name of the person and unmask the value
 void setPos(Pos pos)
          Set the position and unmask the value
 java.lang.String toString()
          Returns a string representation of this Flight object.
 
Methods inherited from class reservation.system.Person
clone, getBookingNumber, getFlight, getPersonName, getPos
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Profile

public Profile()
Construct an empty profile

Method Detail

setPersonName

public void setPersonName(java.lang.String personName)
                   throws java.lang.Exception,
                          java.lang.NullPointerException
Set the name of the person and unmask the value

Overrides:
setPersonName in class Person
Parameters:
personName - name of the person
Throws:
java.lang.Exception - if the invariant _check() is violated
java.lang.NullPointerException - if personName is null

setFlight

public void setFlight(Flight flight)
               throws java.lang.Exception,
                      java.lang.NullPointerException
Set the flight and unmask the value

Overrides:
setFlight in class Person
Parameters:
flight - Flight on witch the person has booked.
Throws:
java.lang.Exception - if the invariant _check() is violated
java.lang.NullPointerException - if flight is null

setBookingNumber

public void setBookingNumber(int bookingNumber)
                      throws java.lang.Exception
Set the booking number and unmask the value

Overrides:
setBookingNumber in class Person
Parameters:
bookingNumber - the booking number
Throws:
java.lang.Exception - if the invariant _check() is violated

setPos

public void setPos(Pos pos)
            throws java.lang.Exception,
                   java.lang.NullPointerException
Set the position and unmask the value

Overrides:
setPos in class Person
Parameters:
pos - The position of the seat on the flight
Throws:
java.lang.Exception - if the invariant _check() is violated
java.lang.NullPointerException - if pos is null

personNameIsMask

public boolean personNameIsMask()
Return true if personName is masked

Returns:
the value of the mask on personName

flightIsMask

public boolean flightIsMask()
Return true if flight is masked

Returns:
the value of the mask on flight

bookingNumberIsMask

public boolean bookingNumberIsMask()
Return true if bookingNumber is masked

Returns:
the value of the mask on bookingNumber

posIsMask

public boolean posIsMask()
Return true if pos is masked

Returns:
the value of the mask on pos

_check

public void _check()
            throws java.lang.Exception
Verify invariants :
     - either the mask is true or the object = null
     

Overrides:
_check in class Person
Throws:
java.lang.Exception - if the invariant is violated

equals

public boolean equals(java.lang.Object anObject)
Overide equals return true if for all fields: person.field. == profile.field || profile.fieldIsMask Where the fields to test are: the name, the flight, the booking number, the seat. The method respects the following conditions: Reflexivity, symmetry, consistency, non-nullity. However, the transitivity in not respected:
 Profile A = new Profile();
 A.setpersonName(“Person”)
 Profile B() = new Profile();
 B.setBookingNumber(1);
 Person P(personName=“Person”, bookingNumber = 1,…);
 A.equals(P);  // true
 B.equals(P);  // true
 A.equals(B);  // false
 
That is why this function of comparison was first named match (). Although the previous properties were not all respected the name of this method have been changed to equals(). The advantage to override this method is that the java.util.List interface, called the equals() methods to identify the object on the following functions:
 •      boolean contains(Object o)
 •      int indexOf(Object o)
 •      boolean remove(Object o)
 
If Object is a Profile, then these methods means respectively: the list match a pattern, return or remove the first element matching a pattern.

Overrides:
equals in class Person
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 Person object; false otherwise

toString

public java.lang.String toString()
Returns a string representation of this Flight 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

Overrides:
toString in class Person
Returns:
a string representation of this Profile object.