|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectreservation.system.Person
reservation.system.Profile
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 = aSeatequals Profile
- flight:Flight = aFlight - personNameMask:boolean = true - bookingNumberMask:boolean = true - posMask:boolean = true
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 |
public Profile()
Method Detail |
public void setPersonName(java.lang.String personName) throws java.lang.Exception, java.lang.NullPointerException
setPersonName
in class Person
personName
- name of the person
java.lang.Exception
- if the invariant _check() is violated
java.lang.NullPointerException
- if personName is nullpublic void setFlight(Flight flight) throws java.lang.Exception, java.lang.NullPointerException
setFlight
in class Person
flight
- Flight on witch the person has booked.
java.lang.Exception
- if the invariant _check() is violated
java.lang.NullPointerException
- if flight is nullpublic void setBookingNumber(int bookingNumber) throws java.lang.Exception
setBookingNumber
in class Person
bookingNumber
- the booking number
java.lang.Exception
- if the invariant _check() is violatedpublic void setPos(Pos pos) throws java.lang.Exception, java.lang.NullPointerException
setPos
in class Person
pos
- The position of the seat on the flight
java.lang.Exception
- if the invariant _check() is violated
java.lang.NullPointerException
- if pos is nullpublic boolean personNameIsMask()
personName
is masked
public boolean flightIsMask()
flight
is masked
public boolean bookingNumberIsMask()
bookingNumber
is masked
public boolean posIsMask()
pos
is masked
public void _check() throws java.lang.Exception
- either the mask is true or the object = null
_check
in class Person
java.lang.Exception
- if the invariant is violatedpublic boolean equals(java.lang.Object anObject)
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); // falseThat 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.
equals
in class Person
anObject
- anObject
- the reference object with which to compare
true
if this object is the same as the obj argument or match a Person
object;
false
otherwisepublic java.lang.String toString()
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
toString
in class Person
Profile
object.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |