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
|
@Override
|
||||||
public int compareTo(Card other) {
|
public int compareTo(Card other) {
|
||||||
//TODO implement
|
// First, compare ranks
|
||||||
return 0;
|
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