becker.xtras.marks
Class SampleMarks

java.lang.Object
  extended by becker.xtras.marks.SampleMarks
All Implemented Interfaces:
IMarks

public final class SampleMarks
extends Object
implements IMarks

A sample class implementing the IMarks interface. It maintains a list of assignment marks for students and performs calculations on them.

Please see the package description for a more in-depth discussion of using this class.

Author:
Byron Weber Becker

Constructor Summary
SampleMarks()
           
SampleMarks(String fileName)
           
 
Method Summary
 void addAssignment(String name)
          Add a new assignment to the marks "spreadsheet."
 void addStudent(String name)
          Add a new student to the marks "spreadsheet."
 String[] getAssignmentCalculationNames()
          Get the names of the calculations provided for assignments.
 String[] getAssignmentNames()
          Get the names of all the assignments.
 int getMark(String sName, String aName)
          Get a mark for a particular student and assignment.
 String[] getStudentCalculationNames()
          Get the names of the calculations provided for students.
 String[] getStudentNames()
          Get the names of the students.
static void main(String[] args)
           
 int performAssignmentCalculation(String calcName, String aName)
          Perform one of the calculations defined for assignments.
 int performStudentCalculation(String calcName, String studentName)
          Perform one of the calculations defined for students.
 void readFile(String fileName)
          Read the marks "spreadsheet" from a file.
 void setMark(String sName, String aName, int mark)
          Set the mark for a particular student and assignment
 void writeFile(String fileName)
          Write the marks "spreadsheet" to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SampleMarks

public SampleMarks(String fileName)

SampleMarks

public SampleMarks()
Method Detail

getMark

public int getMark(String sName,
                   String aName)
Description copied from interface: IMarks
Get a mark for a particular student and assignment.

Specified by:
getMark in interface IMarks
Parameters:
sName - the name of the student
aName - the name of the assignment
Returns:
the mark assigned to this student for this assignment

setMark

public void setMark(String sName,
                    String aName,
                    int mark)
Description copied from interface: IMarks
Set the mark for a particular student and assignment

Specified by:
setMark in interface IMarks
Parameters:
sName - the name of the student
aName - the name of the assignment
mark - the mark to be assigned to this student for this assignment

getStudentNames

public String[] getStudentNames()
Description copied from interface: IMarks
Get the names of the students.

Specified by:
getStudentNames in interface IMarks
Returns:
the names of all the students.

getAssignmentNames

public String[] getAssignmentNames()
Description copied from interface: IMarks
Get the names of all the assignments.

Specified by:
getAssignmentNames in interface IMarks
Returns:
the names of all the assignments

addStudent

public void addStudent(String name)
Description copied from interface: IMarks
Add a new student to the marks "spreadsheet."

Specified by:
addStudent in interface IMarks
Parameters:
name - the name of the new student

addAssignment

public void addAssignment(String name)
Description copied from interface: IMarks
Add a new assignment to the marks "spreadsheet."

Specified by:
addAssignment in interface IMarks
Parameters:
name - the name of the new assignment

getAssignmentCalculationNames

public String[] getAssignmentCalculationNames()
Description copied from interface: IMarks
Get the names of the calculations provided for assignments. For example, one might be "Average". Then calling performAssignmentCalculation("Average", 0) would return the average of all the marks for assignment 0.

Specified by:
getAssignmentCalculationNames in interface IMarks
Returns:
the names of all the calculations provided for assignments

getStudentCalculationNames

public String[] getStudentCalculationNames()
Description copied from interface: IMarks
Get the names of the calculations provided for students. For example, one might be "Average Best Four Assignments". Then calling performStudentCalculation("Average Best Four Assignments", 5) would (presumably) return the average of the best four marks for student 5.

Specified by:
getStudentCalculationNames in interface IMarks
Returns:
the names of all the calculations provided for students

performAssignmentCalculation

public int performAssignmentCalculation(String calcName,
                                        String aName)
Description copied from interface: IMarks
Perform one of the calculations defined for assignments.

Specified by:
performAssignmentCalculation in interface IMarks
Parameters:
calcName - one of the names returned by IMarks.getAssignmentCalculationNames()
aName - the name of the assignment
Returns:
the result of the calculation

performStudentCalculation

public int performStudentCalculation(String calcName,
                                     String studentName)
Description copied from interface: IMarks
Perform one of the calculations defined for students.

Specified by:
performStudentCalculation in interface IMarks
Parameters:
calcName - one of the names returned by IMarks.getStudentCalculationNames()
studentName - the name of the student
Returns:
the result of the calculation

readFile

public void readFile(String fileName)
              throws FileNotFoundException
Description copied from interface: IMarks
Read the marks "spreadsheet" from a file.

Specified by:
readFile in interface IMarks
Parameters:
fileName - the name of the file to read
Throws:
FileNotFoundException

writeFile

public void writeFile(String fileName)
               throws FileNotFoundException
Description copied from interface: IMarks
Write the marks "spreadsheet" to a file.

Specified by:
writeFile in interface IMarks
Parameters:
fileName - the name of the file
Throws:
FileNotFoundException

main

public static void main(String[] args)