Item
public enum Item
{
SANDWICH("sandwich"), CRISPS("crisps"), DRINK("drink");
private String description;
Item(String description)
{
this.description = description;
}
public String toString()
{
return description;
}
}
Character
public enum Character
{
LAURA("Laura",Item.SANDWICH),SALLY("Sally", Item.CRISPS),ANDY("Andy", Item.DRINK),ALEX("Alex", null);
private String charDescription;
private Item item;
private Character(String Chardescription, Item item) {
this.charDescription = charDescription;
this.item = item;
}
public String toString()
{
return charDescription;
}
public boolean take(Item item)
{
}
I wrote these two enumeration classes, where Item contains items with their descriptions and Character has four different Character objects: LAURA, SALLY, ANDY and ALEX, each parameterized with a description and an item. The item may be null.
I need to write a method take(Item item), which takes the indicated item from the character if the character has that item, and returns true if it is successful in taking the item from the character, and false otherwise.
I don't know how to implement this by modifying the parameters of the enum class Character. Any help will be appreciated.