Lab 7 Comparator

CS203
Spring 2017
March 28, 2017

  • Set up teams of two students for this project
  • Create a program utilizing the Comparator interface
  • Include JUnit tests
  • Upload your program to the correct ComparatorTeamx repository in github
  • Find a teammate
  • Create a folder outside of your cs203 folder called ComparatorTeamx where x is your team number.
  • Create a Netbeans project in that folder with the JUnit library included
  • Do exercise 4.12 in Horstmann, which asks you to extend the Country program in chapter 4. The code in the book is available in the Other Materials section of the wiki for this course.
  • Once you have something in the folder, set up a local repository as you did in Lab 1
  • Push your work to the remote repository, ComparatorTeamx.
  • Horstmann 4.12 - Add two methods

public static Comparator<Country> createComparatorByName(final boolean increasing)

public static Comparator<Country> createComparatorByArea(final boolean increasing)

to the Country class. The methods should return instances of anonymous classes that implement the Comparator interface type. The boolean parameters indicate whether the comparison should be in increasing or decreasing order. The parameters are declared final so that you can access them in your compare methods.

NOTE: You do not need to implement Comparable<> to use the String method CompareTo(). However, you may need to implement Comparator<> to create Comparators.

Please include Javadoc comments and tests. This is meant to be a longer lab than the animation lab.