/**
 * Class that represents letter grades (implementing the Grade interface).
 *   @author Dave Reed
 *   @version 11/1/17
 */
class LetterGrade implements Grade {
   private int courseHours;
   private String courseGrade;

   /**
    * Constructs a letter grade.
    *   @param g the grade ("A", "B+", ...)
    *   @param hrs the number of credit hours
    */
   public LetterGrade(String g, int hrs) {
      this.courseGrade = g;
      this.courseHours = hrs;
   }
   
   /**
    * Accessor method for the number of course hours.
    *   @return the course hours
    */
   public int hours() {
      return this.courseHours;
   }
   
   /**
    * Calculates the grade points earned.
    *   @return the grade points (grade * hours)
    */
   public double gradePoints() {
      if (this.courseGrade.equals("A")) {
         return 4.0*this.courseHours;
      }
      else if (this.courseGrade.equals("B+")) {
         return 3.5*this.courseHours;
      }
      else if (this.courseGrade.equals("B")) { 
          return 3.0*this.courseHours;
      }
      else if (this.courseGrade.equals("C+")) {
         return 2.5*this.courseHours;
      }
      else if (this.courseGrade.equals("C")) { 
          return 2.0*this.courseHours;
      }
      else if (this.courseGrade.equals("D")) { 
          return 1.0*this.courseHours;
      }
      else {
          return 0.0;
      }
    }
}

