/** * 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. */ public class Guest implements Comparable { private String name; private String gift; private Natural giftValue; /** * Construct a Guest * @param name The guests name * @param gift The name of the gift brought by this guest * @param giftValue How much the gift is worth in Kopecks. */ public Guest(String name, String gift, Natural giftValue) { this.name = name; this.gift = gift; this.giftValue = giftValue; } /** * Compare two guests, the one with the most expensive gift * is higher. * @param other the guest to be compared to this one. * @return 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. */ public int compareTo(Guest other) { return this.giftValue.compareTo(other.giftValue); } /** * Return the value of this guest's gift. * @return Natural the giftValue */ public Natural giftValue() { return giftValue; } /** * Return a string representation of this guest, * specifically: name + " " + gift + " " + giftValue; * @return a string representation of this guest */ public String toString() { return name + " " + gift + " " + giftValue; } }