/**
   A class that holds a grade for a graded activity.
*/

public class GradedActivity implements Comparable <GradedActivity> 
{
   private double score;  // Numeric score

   /**
      The setScore method sets the score field.
      @param s The value to store in score.
   */

   public void setScore(double s)
   {
      score = s;
   }

   /**
      The getScore method returns the score.
      @return The value stored in the score field.
   */

   public double getScore()
   {
      return score;
   }

   /**
      The getGrade method returns a letter grade
      determined from the score field.
      @return The letter grade.
   */

   public char getGrade()
   {
      char letterGrade;

      if (score >= 90)
         letterGrade = 'A';
      else if (score >= 80)
         letterGrade = 'B';
      else if (score >= 70)
         letterGrade = 'C';
      else if (score >= 60)
         letterGrade = 'D';
      else
         letterGrade = 'F';

      return letterGrade;
   }
   
   /**********************************************
    * compareTo compares the scores of two GradedActivity2
	* objects and returns a 0, 1, or -1 depending on 
	* the comparison of scores
	*
    * @param other The graded activity to compare
	* @returns -1 if this score is less than other, 0 if 
	*          they are the same, 1 if this is greater than
	*          other
	**********************************************/
	public int compareTo(GradedActivity other)
	{
		int result;
		
		if (this.getScore() > other.getScore())
			result = 1;
		else if (this.getScore() < other.getScore())
			result = -1;
		else
			result = 0;
		return result;
	}
	
// 	// ONE POSSIBLE SOLUTION (fix the close comment)
// 	/**********************************************
//     * compareTo compares the scores of two GradedActivity2
// 	* objects and returns a 0, 1, or -1 depending on 
// 	* the comparison of scores
// 	*
//     * @param other The graded activity to compare
// 	* @returns -1 if this score is less than other, 0 if 
// 	*          they are the same, 1 if this is greater than
// 	*          other
// 	**********************************************/
// 	public int compareTo(Object other)
// 	{
// 		GradedActivity2 otherGraded;
// 		
// 		// cast other as a GradedActivity2
// 		otherGraded = (GradedActivity2) other;
// 		
// 		// this will call the more specific of the overloaded methods
// 		return this.compareTo(other);
// 	}

				
}