previous | start | next

Comparator Class for Coins

public class CoinComparator implements Comparator
{
   public int compare(Object firstObject, Object secondObject)
   {
      Coin first = (Coin)firstObject;
      Coin second = (Coin)secondObject;
      if ( first.getValue() < second.getValue() )
         return -1;
      if ( first.getValue() == second.getValue() )
         return 0;
      return 1;
   }
}



previous | start | next