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.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; 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.METAL;
import static edu.kit.informatik.cardgame.model.Card.PLASTIC; import static edu.kit.informatik.cardgame.model.Card.PLASTIC;
import static edu.kit.informatik.cardgame.model.Card.WOOD; import static edu.kit.informatik.cardgame.model.Card.WOOD;
public enum Item { public enum Item {
/**
* Axe. Provides an attack bonus of two.
*/
AXE, AXE,
/**
* Club. Provides an attack bonus of one.
*/
CLUB, CLUB,
/**
* Shack. Can save the last five items.
*/
SHACK, SHACK,
/**
* Fireplace. Required for some advanced items.
*/
FIREPLACE, FIREPLACE,
/**
* Sailing raft. Can be used to attempt an escape.
*/
SAILING_RAFT, SAILING_RAFT,
/**
* Hang glider. Can be used to attempt to escape.
*/
HANG_GLIDER, HANG_GLIDER,
/**
* Steam boat. Can be used to escape.
*/
STEAMBOAT, STEAMBOAT,
/**
* Ballon: making it seem as though a [stranded person] effortlessly becomes airborne,
* floats in the air, and lands softly.
*/
BALLON; BALLON;
/**
* Resources needed to build this item, in no particular order.
*
* @return resources needed to build this item
*/
public Card[] resourcesNeeded() { public Card[] resourcesNeeded() {
switch (this) { switch (this) {
case AXE: 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() { public Collection<Item> itemsNeededToBuild() {
switch (this) { switch (this) {
case BALLON: 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() { public int fightingBonus() {
switch (this) { switch (this) {
case AXE: 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) { public static Item parse(String input) {
switch (input) { switch (input) {
case "axe": 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 @Override
public String toString() { public String toString() {
switch (this) { switch (this) {