From 2de3bf57cd21d5cf60723fca59f61d3bc69578dd Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Wed, 22 Jul 2015 12:34:32 +0200 Subject: Finished basic Cardbase tests, doing CLI next --- src/eu/equalparts/cardbase/cards/Card.java | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/eu/equalparts/cardbase/cards') 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 -- cgit v1.2.3