Class Guest

java.lang.Object
  extended by Guest
All Implemented Interfaces:
java.lang.Comparable<Guest>

public class Guest
extends java.lang.Object
implements java.lang.Comparable<Guest>

Guest is a person visiting the King. A guest has a name and a gift. The gift has a value in "Kopecks" (a Natural number). Guests can be compared by the value of their gifts.


Constructor Summary
Guest(java.lang.String name, java.lang.String gift, Natural giftValue)
          Construct a Guest
 
Method Summary
 int compareTo(Guest other)
          Compare two guests, the one with the most expensive gift is higher.
 Natural giftValue()
          Return the value of this guest's gift.
 java.lang.String toString()
          Return a string representation of this guest, specifically: name + " " + gift + " " + giftValue;
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Guest

public Guest(java.lang.String name,
             java.lang.String gift,
             Natural giftValue)
Construct a Guest

Parameters:
name - The guests name
gift - The name of the gift brought by this guest
giftValue - How much the gift is worth in Kopecks.
Method Detail

compareTo

public int compareTo(Guest other)
Compare two guests, the one with the most expensive gift is higher.

Specified by:
compareTo in interface java.lang.Comparable<Guest>
Parameters:
other - the guest to be compared to this one.
Returns:
0 if the two guests gifts are equal, -1 if this guest has a cheaper gift, +1 if this guest has a more expensive gift.

giftValue

public Natural giftValue()
Return the value of this guest's gift.

Returns:
Natural the giftValue

toString

public java.lang.String toString()
Return a string representation of this guest, specifically: name + " " + gift + " " + giftValue;

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this guest