|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface IMarks
An interface to model a "spreadsheet" recording student assignment marks.
Object and implements
IMarks. Get it to compile by including stubs for each
method in the IMarks interface. (A stub contains just
enough code to compile -- no more. If
the method has a void return type, the method's body
will not contain any code. If the method returns a string, then
include return "dummy"; as the only line of code in
the body. A method returning an array of strings could contain
return new String[0];.) main
method as suggested in the becker.xtras.marks package documentation,
and debug the program so it runs without errors (but doesn't do
much). getAssignmentNames, getStudentNames,
getMark, and setMark so they do the right
thing. Test your program.saveFile. Run the program to test it and use
it to create a file with the data you put in the arrays manually.
Complete openFile so that it reads the data from a
file into the arrays.addAssignment and addStudent.
A complete solution will verify that the arrays have enough room for
the new information, expanding the arrays as necessary.getAssignmentCalculationNames. Write
the method performAssignmentCalculation. It will typically
have a structure like this:
public int performAssignmentCalculation(String calcName, String assignmentName)
{ if (calcName.equals("Average"))
{ // call a method to calculate the average for the given assignment
} else if (calcName.equals("Min"))
{ // call a method to calculate the minimum mark for the given assignment
} else ...
}When your calculations for each assignment are working, get the
calculations for each student working in the same way.
| 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 studentName,
String assignName)
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. |
int |
performAssignmentCalculation(String calcName,
String assignName)
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 studentName,
String assignName,
int mark)
Set the mark for a particular student and assignment |
void |
writeFile(String fileName)
Write the marks "spreadsheet" to a file. |
| Method Detail |
|---|
int getMark(String studentName,
String assignName)
studentName - the name of the studentassignName - the name of the assignment
void setMark(String studentName,
String assignName,
int mark)
studentName - the name of the studentassignName - the name of the assignmentmark - the mark to be assigned to this student for this assignmentString[] getAssignmentNames()
String[] getStudentNames()
void addAssignment(String name)
name - the name of the new assignmentvoid addStudent(String name)
name - the name of the new studentString[] getAssignmentCalculationNames()
performAssignmentCalculation("Average", 0) would return the
average of all the marks for assignment 0.
String[] getStudentCalculationNames()
performStudentCalculation("Average Best Four Assignments", 5)
would (presumably) return the average of the best four marks for student 5.
int performAssignmentCalculation(String calcName,
String assignName)
calcName - one of the names returned by getAssignmentCalculationNames()assignName - the name of the assignment
int performStudentCalculation(String calcName,
String studentName)
calcName - one of the names returned by getStudentCalculationNames()studentName - the name of the student
void readFile(String fileName)
throws FileNotFoundException
fileName - the name of the file to read
FileNotFoundException
void writeFile(String fileName)
throws FileNotFoundException
fileName - the name of the file
FileNotFoundException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||