diff options
author | Eduardo Pedroni <e.pedroni91@gmail.com> | 2015-07-22 12:34:32 +0200 |
---|---|---|
committer | Eduardo Pedroni <e.pedroni91@gmail.com> | 2015-07-22 12:34:32 +0200 |
commit | 2de3bf57cd21d5cf60723fca59f61d3bc69578dd (patch) | |
tree | fb2efa7507c25f80b9e05983dc6e1acb69861f16 /src/eu/equalparts/cardbase/cards | |
parent | 2227aaf4cdee9535dedc28d570d6fdf2d38d1fe3 (diff) |
Finished basic Cardbase tests, doing CLI next
Diffstat (limited to 'src/eu/equalparts/cardbase/cards')
-rw-r--r-- | src/eu/equalparts/cardbase/cards/Card.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/eu/equalparts/cardbase/cards/Card.java b/src/eu/equalparts/cardbase/cards/Card.java index 419861b..1d8fbb9 100644 --- a/src/eu/equalparts/cardbase/cards/Card.java +++ b/src/eu/equalparts/cardbase/cards/Card.java @@ -57,5 +57,39 @@ public class Card { return clone; } + + public static int makeHash(String setCode, String number) { + final int prime = 31; + int result = 1; + result = prime * result + ((number == null) ? 0 : number.hashCode()); + result = prime * result + ((setCode == null) ? 0 : setCode.hashCode()); + return result; + } + @Override + public int hashCode() { + return makeHash(setCode, number); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Card other = (Card) obj; + if (number == null) { + if (other.number != null) + return false; + } else if (!number.equals(other.number)) + return false; + if (setCode == null) { + if (other.setCode != null) + return false; + } else if (!setCode.equals(other.setCode)) + return false; + return true; + } }
\ No newline at end of file |