[SOLVED] This assignment is built on top of Assignment 6

25.00 $

Programming resource
, Digital learning resource
Categories: ,
Practical programming resource
Suitable for guided study and reference
Tutor guidance available when needed

Description

5/5 - (2 votes)

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
}
}Extra credit information:
1. If Lab6 submitted by March 12th midnight – you attempt any ec assignment you can earn full
points.
2. If Lab6 submitted by March 15th midnight – you attempt any ec assignment you can 50% of earned
points.EC1 – Lab 8 [25 points] – You design, develop and test.
Using Lab 7 – add capability for student (add to Printable interface) to compute and print grade.
If total score is 91 – Print A-
Pl. use the following rubric.
For Letter Grade:
Grade: A+ assigned with 97% or higher
Grade: A assigned with 93% or higher
Grade: A- assigned with 90% or higher
Grade: B+ assigned with 87% or higher
Grade: B assigned with 83% or higher
Grade: B- assigned with 80% or higher
Grade: C+ assigned with 77% or higher
Grade: C assigned with 73% or higher
Grade: D+ assigned with 70% or higher
Grade: D assigned with 63% or higher
Grade: D- assigned with 60% or higher
Grade: F assigned with 0% or higherEC2 – Lab 7 – if submitted by 3/19 midnight PST (+2 hours) – extra 10 points.EC3 – Still thinking.DEBUG flag –
//Just an example of how to implement DEBUG flag
public interface GBCons {
public final boolean DEBUG = true;
}public class Someclass implements GBCons {public void printstats() {
//let’s say u write code to deserialize a file
StudentReport r = …..;
if(r!=null)
if(DEBUG)
r.getStats.print();

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.