Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class Test{
- public static void main(String argv[]){
- DataBase db = new DataBase();
- db.addStudent(185844,"Bodzio","Ch");
- db.addStudent(188966,"Kacper","P");
- db.addCourse(0,"AiSD",6);
- db.addCourse(1,"KP1",4);
- db.addCourse(2,"WdFTI",3);
- db.addGrade(185844,0,4.0);
- db.addGrade(185844,1,5.5);
- db.addGrade(185844,2,4.0);
- db.addGrade(188966,0,3.0);
- db.addGrade(188966,1,5.0);
- db.addGrade(188966,2,3.0);
- String filename = "./test.dat";
- try {
- ObjectOutputStream out = new ObjectOutputStream(
- new BufferedOutputStream(
- new FileOutputStream(filename)));
- out.writeObject(db);
- out.close();
- } catch (FileNotFoundException fnfe) {
- System.err.println("OUT: whoOps!");
- } catch (IOException ioe){
- System.err.println("OUT: whoOps1!");
- }
- DataBase db2 = new DataBase();
- try {
- ObjectInputStream in = new ObjectInputStream(
- new BufferedInputStream(
- new FileInputStream(filename)));
- db2 = (DataBase)in.readObject();
- in.close();
- } catch (ClassNotFoundException cnfe){
- System.err.println("IN: whoOps!");
- } catch (FileNotFoundException fnfe) {
- System.err.println("IN: whoOps1!");
- } catch (IOException ioe){
- System.err.println("IN: whoOps2!");
- }
- System.out.println(db2.studentInfo(185844) + "\n" + db.makeStudentChart(185844).toString());
- System.out.println(db2.studentInfo(188966) + "\n" + db.makeStudentChart(188966).toString());
- System.out.println(db2.studentInfo(185847));
- }
- }
Add Comment
Please, Sign In to add comment