implemented compareTo method
This commit is contained in:
parent
196ed3ec0f
commit
4b03f5d629
Binary file not shown.
@ -23,7 +23,15 @@ public record Card(Rank rank, Suit suit) implements Comparable<Card> {
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(Card other) {
|
||||
//TODO implement
|
||||
return 0;
|
||||
// First, compare ranks
|
||||
int rankComparison = this.rank.compareTo(other.rank);
|
||||
|
||||
if (rankComparison != 0) {
|
||||
// If ranks are different, return the comparison result
|
||||
return rankComparison;
|
||||
} else {
|
||||
// If ranks are equal, compare suits
|
||||
return this.suit.compareTo(other.suit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user