diff options
author | Eduardo Pedroni <ep625@york.ac.uk> | 2015-07-13 03:31:02 +0200 |
---|---|---|
committer | Eduardo Pedroni <ep625@york.ac.uk> | 2015-07-13 03:31:02 +0200 |
commit | 19183986d37c5ca1a31a5b308bace92b87430ffe (patch) | |
tree | fc2bf0fc6bed0fa836a8c1401f16d967b639b491 /src/eu/equalparts/cardbase/utils | |
parent | e319b8b0790d442d836958df41302af91d750313 (diff) |
Added some statistics functionality, TDD
Diffstat (limited to 'src/eu/equalparts/cardbase/utils')
-rw-r--r-- | src/eu/equalparts/cardbase/utils/MTGUniverse.java | 6 | ||||
-rw-r--r-- | src/eu/equalparts/cardbase/utils/UID.java | 33 |
2 files changed, 36 insertions, 3 deletions
diff --git a/src/eu/equalparts/cardbase/utils/MTGUniverse.java b/src/eu/equalparts/cardbase/utils/MTGUniverse.java index b52c3e6..1e8efc2 100644 --- a/src/eu/equalparts/cardbase/utils/MTGUniverse.java +++ b/src/eu/equalparts/cardbase/utils/MTGUniverse.java @@ -12,9 +12,9 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; -import eu.equalparts.cardbase.data.Card; -import eu.equalparts.cardbase.data.CardSetInformation; -import eu.equalparts.cardbase.data.FullCardSet; +import eu.equalparts.cardbase.cards.Card; +import eu.equalparts.cardbase.cards.CardSetInformation; +import eu.equalparts.cardbase.cards.FullCardSet; /** * Access point to the complete set of cards that exist in the diff --git a/src/eu/equalparts/cardbase/utils/UID.java b/src/eu/equalparts/cardbase/utils/UID.java new file mode 100644 index 0000000..ae4a11d --- /dev/null +++ b/src/eu/equalparts/cardbase/utils/UID.java @@ -0,0 +1,33 @@ +package eu.equalparts.cardbase.utils; + +import eu.equalparts.cardbase.cards.Card; + +public class UID { + + /** + * Used in the hash generation. + */ + private static final String HASH_DIVIDER = "~"; + + /** + * Generate the hash used as a key in the storage map. + * + * @param setCode the card's set code. + * @param number the card's set number. + * @return the generated hash. + */ + public static String makeHash(String setCode, String number) { + return setCode + HASH_DIVIDER + number; + } + + /** + * Generate the hash used as a key in the storage map. + * + * @param the {@code Card} whose hash is desired. + * @return the generated hash. + */ + public static String makeHash(Card card) { + return card.setCode + HASH_DIVIDER + card.number; + } + +} |