java.lang.ObjectGuest
public class 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 |
|---|
public Guest(java.lang.String name,
java.lang.String gift,
Natural giftValue)
name - The guests namegift - The name of the gift brought by this guestgiftValue - How much the gift is worth in Kopecks.| Method Detail |
|---|
public int compareTo(Guest other)
compareTo in interface java.lang.Comparable<Guest>other - the guest to be compared to this one.
public Natural giftValue()
public java.lang.String toString()
name + " " + gift + " " + giftValue;
toString in class java.lang.Object