Java

OOP GUIDE / WORK

 

CARD CLASS 2

 

Topics

  • Implementing the compareTo method
  • Sorting object arrays with Comparable

 

 

TASK – PART 1 – SETUP

 

Copy and paste (if necessary) the following two classes from the Card Class work solutions:

 

  • Card class
  • Tester class (the one at the bottom of the solutions)

 

TASK – PART 2 – ALTERING COMPARETO

 

Alter the compareTo method inside Card to sort all cards by suit.  All cards of the same suit should be sorted by numeric.

 

Order of suits: Clubs, Diamonds, Spades and then Hearts.

 

TASK – PART3 – TESTING

 

Alter the Tester class to create 10 different Cards.  Sort them and see if your implementation of compareTo is working properly.