Hi, I'm trying to write a program where the user enters his/her exam results
and the programme states whether the user has passed or failed. I am
supposed to write the program so that the public ModuleResult result()
method of the ModuleRecord class prints whether the users module result is a
pass, fail, or compensatable fail through accessing the ModuleResult class,
which I am not allowed to alter. I think that I have written the result()
method of the ModuleRecord class correctly to the extent that 'score' will
equal whatever 'result' will equal once a String has been entered into
private ModuleResult(String result). My problem is trying to write the
ModuleRecord class correctly so that the value of 'result' will be right.
As you can probably tell I'm a Java newbie, and I struggle to explain things
Java related clearly, but I hope one of you can understand my problem and
put me in the right direction.
Thanks.
public class ModuleRecord
{
private Module mod;
private int examMark;
private int courseMark;
private ModuleResult modResult;
public ModuleRecord(Module m, int eMark, int cMark)
{
mod = m;
examMark = eMark;
courseMark = cMark;
}
public ModuleResult result()
{
String score = modResult.toString();
return score;
}
} // End Class ModuleRecord
public class ModuleResult
{
private static String PASS_STRING = "Pass";
private static String COMPENSATABLE_FAIL_STRING = "Compensatable Fail";
private static String FAIL_STRING = "Fail";
private String result;
public static final int COMPENSATION_THRESHOLD = 35;
public static final int PASS_MARK = 40;
public static final ModuleResult PASS = new ModuleResult(PASS_STRING);
public static final ModuleResult COMPENSATABLE_FAIL = new ModuleResult(COMPENSATABLE_FAIL_STRING);
public static final ModuleResult FAIL = new ModuleResult(FAIL_STRING);
private ModuleResult(String result)
{
this.result = result;
}
public String toString()
{
return result;
}
}