Javadoc for Item

This commit is contained in:
Arne Keller 2020-03-12 09:28:03 +01:00
parent 0eac34a6c7
commit 1388d78244

View File

@ -3,22 +3,51 @@ package edu.kit.informatik.cardgame.model;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import static edu.kit.informatik.cardgame.model.Card.METAL;
import static edu.kit.informatik.cardgame.model.Card.PLASTIC;
import static edu.kit.informatik.cardgame.model.Card.WOOD;
public enum Item {
/**
* Axe. Provides an attack bonus of two.
*/
AXE,
/**
* Club. Provides an attack bonus of one.
*/
CLUB,
/**
* Shack. Can save the last five items.
*/
SHACK,
/**
* Fireplace. Required for some advanced items.
*/
FIREPLACE,
/**
* Sailing raft. Can be used to attempt an escape.
*/
SAILING_RAFT,
/**
* Hang glider. Can be used to attempt to escape.
*/
HANG_GLIDER,
/**
* Steam boat. Can be used to escape.
*/
STEAMBOAT,
/**
* Ballon: making it seem as though a [stranded person] effortlessly becomes airborne,
* floats in the air, and lands softly.
*/
BALLON;
/**
* Resources needed to build this item, in no particular order.
*
* @return resources needed to build this item
*/
public Card[] resourcesNeeded() {
switch (this) {
case AXE:
@ -42,6 +71,11 @@ public enum Item {
}
}
/**
* Items required to be able to build this item. Building this item does not consume the items returned.
*
* @return items required to build this item
*/
public Collection<Item> itemsNeededToBuild() {
switch (this) {
case BALLON:
@ -52,6 +86,11 @@ public enum Item {
}
}
/**
* Get the fighting bonus of this item against animals.
*
* @return fighting bonus of this item
*/
public int fightingBonus() {
switch (this) {
case AXE:
@ -63,6 +102,13 @@ public enum Item {
}
}
/**
* Parse a single word and return the item represented by the input.
* Fun fact: Item.parse(item.toString()) == item is true for all items.
*
* @param input text
* @return parsed item or null if not found
*/
public static Item parse(String input) {
switch (input) {
case "axe":
@ -86,6 +132,12 @@ public enum Item {
}
}
/**
* Get the textual representation of this item.
* Fun fact: Item.parse(item.toString()) == item is true for all items.
*
* @return textual representation of this item
*/
@Override
public String toString() {
switch (this) {