public class PowerBallEntry
{
  private int[] whiteBalls;
  private int   redBall;
  
  public PowerBallEntry()
  {
    Die bigBin   = new Die( 55 );
    Die smallBin = new Die( 42 );
    
    whiteBalls = bigBin.uniqueRolls( 5 );
    redBall    = smallBin.roll();
  }
  
  public String toString()
  {
    String result = "";
    
    for (int i = 0; i < whiteBalls.length; i++)
      result += whiteBalls[i] + " ";
    result += "... " + redBall;
    
    return result;
  }
  
  // ----- solution to the in-class exercise
  
  public int redBall()
  {
    return redBall;
  }
  
  public boolean matches( PowerBallEntry another )
  {
    if ( !( redBall == another.redBall() ) )
      return false;
    
    for (int i = 0; i < whiteBalls.length; i++)
      if ( ! another.contains( whiteBalls[i] ) )
            return false;
    
    return true;
  }
  
  public boolean contains( int otherWhiteBall )
  {
    for (int i = 0; i < whiteBalls.length; i++)
      if ( otherWhiteBall == whiteBalls[i] )
            return true;
    return false;
  }
}