package datamanagement;

public class StudentUnitRecord implements IStudentUnitRecord
{
	
	//===========================================================================
  // Variables
  //===========================================================================

	
	
	private Integer studentId_;
	private String unitCode_;
	private float assessmentOneMark_, assessmentTwoMark_, examMark_; // Separate out onto multiple lines?
																																	 // Use 'mark' or 'grade' or some other name?
	
	
	//===========================================================================
  // Constructors
  //===========================================================================
	
	
	
	public StudentUnitRecord(Integer studentId, String unitCode, 
			float assessmentOneMark, float assessmentTwoMark, float examMark)
	{
		this.studentId_ = studentId;
		this.unitCode_ = unitCode;
		this.setAssessmentOneMark(assessmentOneMark);
		this.setAssessmentTwoMark(assessmentTwoMark);
		this.setExamMark(examMark);
	}

	
	
	//===========================================================================
  // Accessors
  //===========================================================================
	
	
	
	public Integer getStudentID()
	{
		return studentId_;
	}

	
	
	public String getUnitCode()
	{
		return unitCode_;
	}

	
	
	public float getAssessmentOneMark()
	{
		return assessmentOneMark_;
	}
	
	
	
	public float getAssessmentTwoMark()
	{
		return assessmentTwoMark_;
	}

	
	
	public float getExamMark()
	{
		return examMark_;
	}

	
	
	public float getTotal() // Get total mark? get grade/final grade?
	{
		return assessmentOneMark_ + assessmentTwoMark_ + examMark_;

	}
	
	
	
	public void setAssessmentOneMark(float newMark) // newMark vs assessmentOneMark?
	{
		if (newMark < 0 || 
				newMark > UnitManager.UM().getUnit(unitCode_).getAsg1Weight()) { // Split over two lines? Create validation method?
			throw new RuntimeException(
					"Mark cannot be less than zero or greater than assessment weight");
		}
		this.assessmentOneMark_ = newMark;
	}

	
	
	public void setAssessmentTwoMark(float newMark)
	{
		if (newMark < 0 || 
				newMark > UnitManager.UM().getUnit(unitCode_).getAsg2Weight()) { // Split over two lines? Create validation method?
			throw new RuntimeException(
					"Mark cannot be less than zero or greater than assessment weight");
		}
		this.assessmentTwoMark_ = newMark;
	}

	
	
	public void setExamMark(float newMark) // As above, or different?
	{
		if (newMark < 0 || 
				newMark > UnitManager.UM().getUnit(unitCode_).getExamWeight()) { // Split over two lines? Create validation method?
			throw new RuntimeException(
					"Mark cannot be less than zero or greater than assessment weight");
		}
		this.examMark_ = newMark;
	}

}

@@ -1766,32 +1766,74 @@
 %7B%0A%09%09
-if (newMark %3C 0 %7C%7C %0A%09%09%09%09
+boolean isNegative = newMark %3C 0;%0A%09%09boolean isGreaterThanWeight = 
 newM
@@ -1846,32 +1846,37 @@
 UnitManager.UM()
+%0A%09%09%09%09
 .getUnit(unitCod
@@ -1898,62 +1898,55 @@
 ht()
-) %7B // Split over two lines? Create validation method?
+;%0A%09%09%0A%09%09if (isNegative %7C%7C isGreaterThanWeight) %7B
 %0A%09%09%09
@@ -2086,32 +2086,69 @@
 newMark;%0A%09%7D%0A%0A%09%0A%09
+// See 5.7 - #53 Complex Conditionals
 %0A%09public void se
@@ -2184,38 +2184,81 @@
 ark)
+ 
 %0A%09%7B%0A%09%09
-if (newMark %3C 0 %7C%7C %0A%09%09%09%09
+boolean isNegative = newMark %3C 0;%0A%09%09boolean isGreaterThanWeight = 
 newM
@@ -2271,32 +2271,37 @@
 UnitManager.UM()
+%0A%09%09%09%09
 .getUnit(unitCod
@@ -2323,62 +2323,56 @@
 ht()
-) %7B // Split over two lines? Create validation method?
+;%0A%09%09%0A%09%09if (isNegative %7C%7C isGreaterThanWeight) %7B 
 %0A%09%09%09

Split up complex condition in if statement - see lines 87 - 94