Add capability to handle Grade Book for different subjects

This assignment is built on top of Assignment 6.
Add capability to handle Grade Book for different subjects (Chemistry and Computer Science).
We will assume a maximum of five assignments and up to 40 students.
Details will be provided in the classFrom Lab 6 -
You have a Printable interface - used by Student.
Steps for completing Lab 7 -1. Create a new interface for Faculty to use:
package adapter;
public interface Createable {
public void createGradeBook(String fname);
public void printGradeBook();
}

2. Create a class called InstructorReport
package model;
public class InstructorReport {
private Student s[] = null;
private Statistics st = null;
public InstructorReport(Student [] s, Statistics st){
this.s = s;
this.st = st
}public void print() {
//call a method that print all student info.
//st.print();
}
}

3. Add methods in Util or FileIO class (Util package) to serialize and deserialize
InstructorReport.public void writetodisk(InstructorReport a1, String fname)
{
try {
FileOutputStream p = new FileOutputStream(fname);
ObjectOutputStream p1 = new ObjectOutputStream(p);
p1.writeObject(a1);
}
catch(Exception e)
{
//exception message
}
}public InstructorReport readfromdisk(String fname)
{
InstructorReport a= null;
try {
FileInputStream p = new FileInputStream(fname);
ObjectInputStream p1 = new ObjectInputStream(p);
a = (InstructorReport)p1.readObject();
}
catch(Exception e)
{
//exception message
}
return a;
}

4. Rename your Print class to CreatePrint.
package adapter;
public abstract class CreatePrint {
private Util u = new Util();
private Student arr[] = new Student[40];
private Statistics s = new Statistics();
private StudentReport arr2[] = new StudentReport[40];public void createGradeBook(String fname) {
//This method must be called first - before printGradeBook() or getStats() or printStudentScores()
//we will call existing methods to:
//a. read the file and build a student array - call readFile in Util
//b. compute statistics. - call methods in Statistics
//c. build StudentReport array [done in lab 6]
//d. serialize studentreport - upto 40 files. [done in lab 6]
//e. For instructor - write one file (serialized) with Student [] and Statistics[]
}public void printGradeBook() { }
//use debug flag for printing. if debug = true then print other no printing.public void getStats() {
//print stats from any object - read one object from disk and print stats.
}public void printstudentscores(int id) {
//use the serialized life so your life is easy.
//pl. don't use search in studentreport array. long way. no good.
}}

5. Create a class called GradeBook that extends the abstract class called CreatePrint
package adapter;
public class GradeBook extends CreatePrint implements Creatable, Printable {}//default package.
6. Testing your code
public class Driver7 {
public static void main(String [] args)
{
//Test Instructor interface
Creatable p = new GradeBook();
String fname = "c:\path to filename";
p.createGradeBook(fname);
p.printGradeBook();
//next three lines should give a compiler error - can you say why?
//p.getStats();
//p.printstudentscores(1234);
//p.printstudentscores(9111); //invalid student id shld print a friendly
message - no such student.
//Test Student Interface
Printable s = p;
s.getStats();
s.printstudentscores(1234);
s.printstudentscores(9111); //invalid student id shld print a f
}
}
Powered by