/** Grade is an enumerated class consisting of all of the valid
    grades in this system.
	 
	 @author Nancy Harris, James Madison University
	 @version V1 03/23/2008
	*/
	
public enum Grade
{
	A("A", 4.0, true, true),
	AMINUS("A-", 3.7, true, true),
	BPLUS("B+", 3.3, true, true),
	B("B", 3.0, true, true),
	BMINUS("B-", 2.7, true, true),
	CPLUS("C+", 2.3, true, true),
	C("C", 2.0, true, true),
	CMINUS("C-", 1.7, true, true),
	DPLUS("D+", 1.3, true, true),
	D("D", 1.0, true, true),
	F("F", 0.0, false, true),
	CR("CR", 0.0, true, false),
	NC("NC", 0.0, false, false),
	TR("TR", 0.0, true, false),
	I("I", 0.0, false, false),
	W("W", 0.0, false, false),
	WP("WP", 0.0, false, false),
	WF("WF", 0.0, false, false);
	
	String symbol;
	double qp;
	boolean success;
	boolean graded;

	/** Grade - explicit value constructor
	 *
	 @param inSymbol The grade symbol to print
	 @param inQp The quality points for the grade
	 @param inSuccess Whether the grade indicates successful completion
	 @param inGraded Whether or not the grade counts toward GPA
	 */
	Grade (String grade, double qualPoints, boolean graded, boolean earned)
	{
		this.symbol = grade;
		this.qp = qualPoints;
		this.success = earned;
		this.graded = graded;
	}
	
	/** getGrade provides the symbol for this grade
	 *
	 * @return The symbol for the grade
	 */
	public String getGrade()
	{
	 	return symbol;
	}
	
	public static Grade getGrade(String inGrade)
	{
		Grade out;
		out = null;
		for (Grade g : Grade.values())
		{
			if (g.symbol.equals(inGrade))
				out = g;
		}
		
		return out;
	}
	/** getQp provides the quality points for this grade
	 *
	 * @return The quality points for this grade
	 */
	public double getQP()
	{
	 	return qp;
	}
	
	/** isSuccess provides whether this is a successful attempt
	 *
	 * @return true if this is a successful grade, false otherwise
	 */
	public boolean isEarned()
	{
	 	return success;
	}
	/**isGraded provides whether this is a grade that contributes to GPA
	 *
	 * @return true if this grade contributes to GPA, false otherwise
	 */
	public boolean isGraded()
	{
	 	return graded;
	}
	
	/** toString provides all the values for this grade
	 *
	 * @return the name, symbol, qp, success, and earned for this grade
	 */
	public String toString()
	{
	 	return (this.name() + " " + symbol + " " + qp + " " + success + " " + graded);
	}	
}