Class ComparableResult

java.lang.Object
  |
  +--ComparableResult
All Implemented Interfaces:
java.lang.Comparable, StudentResults

class ComparableResult
extends java.lang.Object
implements java.lang.Comparable, StudentResults

Creates a Comparable Object and implements StudentResults and Comparable

Version:
BETA 26-SEP-2003 Note: This class is incomplete BETA version.
Author:
Ned Martin 4052992

Field Summary
(package private)  int[] marks
           
(package private)  java.lang.String name
           
 
Constructor Summary
ComparableResult(java.lang.String studentname)
          Constructor
 
Method Summary
 void addToCourseWorkMark(int extraMark)
          A student's course work mark may be composed of a collection of marks and this method allows a new mark to be added to that collection.
 int compareTo(java.lang.Object s)
          Compares two Objects
 int getCourseWorkMark()
          The course work mark is calculated from the course work marks added to the collection of course work marks for the student.
 int getExamMark()
          The exam mark for the student
 int getFinalMark()
          The final mark for a student is calculated from the exam and coursework marks.
 java.lang.String getName()
          The name of the student for whoon results are stored.
 void setExamMark(int mark)
          The exam mark for a student can be stored or updated
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

marks

int[] marks

name

java.lang.String name
Constructor Detail

ComparableResult

public ComparableResult(java.lang.String studentname)
Constructor
Parameters:
String - containing Student Name
Method Detail

getName

public java.lang.String getName()
The name of the student for whoon results are stored.
Specified by:
getName in interface StudentResults
Returns:
the name of the student

setExamMark

public void setExamMark(int mark)
The exam mark for a student can be stored or updated
Specified by:
setExamMark in interface StudentResults
Parameters:
mark - the student's exam result

getExamMark

public int getExamMark()
The exam mark for the student
Specified by:
getExamMark in interface StudentResults
Returns:
the student's exam mark

addToCourseWorkMark

public void addToCourseWorkMark(int extraMark)
A student's course work mark may be composed of a collection of marks and this method allows a new mark to be added to that collection.
Specified by:
addToCourseWorkMark in interface StudentResults
Parameters:
extraMark - the next mark to be added

getCourseWorkMark

public int getCourseWorkMark()
The course work mark is calculated from the course work marks added to the collection of course work marks for the student.
Specified by:
getCourseWorkMark in interface StudentResults
Returns:
the final coursework mark for the student

getFinalMark

public int getFinalMark()
The final mark for a student is calculated from the exam and coursework marks.
Specified by:
getFinalMark in interface StudentResults
Returns:
the student's final mark

compareTo

public int compareTo(java.lang.Object s)
              throws java.lang.ClassCastException
Compares two Objects
Specified by:
compareTo in interface java.lang.Comparable
Parameters:
Object - s to compare, representing student marks
Returns:
-1 if this student's final mark is less than s's final mark or the final marks are the same but this student’s exam mark is less than s’s exam mark or both the final and exam marks are the same but this student's name is less than s's name. 0 if all of the final mark, exam mark and name are the same. +1 if this student's final mark is greater than s's final mark or the final marks are the same but this student’s exam mark is greater than s’s exam mark or both the final and exam marks are the same but this student's name is greater than s's name.
Throws:
java.lang.ClassCastException - if Object is not a ComparableResult Object. Note: This method is incomplete.