/** * The method checks if this Square and specified object (Square) are equal. * * @param obj - specified object. * @return boolean true if this Square is equal to specified object and false otherwise. */ public boolean equals(final Object obj) { if (obj instanceof Square) { final Square square = (Square) obj; return rank.equals(square.rank); } return false; }
/** * Returns player's card. * * @param player who is on turn. * @param trump suit. * @return Card object instance or null. */ public Card getPlayMethodCard(final Player player, final Suit trump) { Card result = null; for (final SuitIterator iterator = Suit.iterator(); iterator.hasNext(); ) { final Suit suit = iterator.next(); final Card card = player.getCards().findMinSuitCard(suit); if (card != null && !suit.equals(trump)) { final int suitCount = player.getCards().getSuitCount(suit); final boolean isSingle = suitCount == 1; final boolean isMeter = suitCount + getPassedSuitCardsCount(suit) == Rank.getRankCount(); final Card max = player.getCards().findMaxSuitCard(suit); final boolean powerSuit = max != null && isMaxSuitCardLeft(max, true); if (isSingle && !powerSuit && !isMeter && max != null && max.compareRankTo(Rank.King) <= 0) { if (result == null || result.compareRankTo(card) > 0) { result = card; } } } } return result; }
/** * Returns a string representation of the object. The return name is based on class short name. * This method has to be used only for debug purpose when the project is not compiled with * obfuscating. Don't use this method to represent the object. When the project is compiled with * obfuscating the class name is not the same. * * @return String a string representation of the object. */ public String toString() { return String.valueOf(rank.getSquarePoints()) + "(4x" + rank.getRankSign() + ")"; }
/** * Returns hash code. * * @return hash code. */ public int hashCode() { return rank.hashCode(); }
/** * Compares this Square with the specified object(Square) for order. * * @param obj - specified object (Square). * @return int value which may be: = 0 if this Square and the specified object(Square) are equal > * 0 if this Square is bigger than the specified object(Square) < 0 if this EqSquareualCards * is less than the specified object(Square) */ public int compareTo(final Object obj) { final Square square = (Square) obj; return rank.compareToAT(square.rank); }
/** * Returns Square points. * * @return int square points. */ public int getPoints() { return rank.getSquarePoints(); }