From 817a6c2925279ab471ac960730e6c00c1285a7e7 Mon Sep 17 00:00:00 2001 From: Romputer Date: Wed, 12 Jun 2019 22:02:52 +0300 Subject: [PATCH] Minor changes --- src/CentralRegistry.java | 56 +++++++++++++++++++--------------------- src/LogRegCheck.java | 2 +- 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/src/CentralRegistry.java b/src/CentralRegistry.java index 8710293..acbff3e 100644 --- a/src/CentralRegistry.java +++ b/src/CentralRegistry.java @@ -8,7 +8,7 @@ public class CentralRegistry private static ArrayList students; - public static boolean initializedList = false; + private static boolean initializedList = false; @SuppressWarnings("unchecked") @@ -41,6 +41,28 @@ public static void desirializeUsers(){ c.printStackTrace(); } } + + public static void serializeUsers() { + + String filename = "student.ser"; + + // Serialization + try{ + //Saving of student in a file + FileOutputStream file = new FileOutputStream(filename); + ObjectOutputStream out = new ObjectOutputStream(file); + + // Method for serialization of Student s + out.writeObject(students); + + out.close(); + file.close(); + + // System.out.println("Serialization worked"); + }catch(IOException ex) { + System.out.println("IOException is caught"); + } + } public static Student registerNewUser() { @@ -53,34 +75,6 @@ public static Student registerNewUser() { return s.get(s.indexOf(stud)); } - - - - public static void serializeUsers() { - - String filename = "student.ser"; - - // Serialization - try{ - //Saving of student in a file - FileOutputStream file = new FileOutputStream(filename); - ObjectOutputStream out = new ObjectOutputStream(file); - - // Method for serialization of Student s - out.writeObject(students); - - out.close(); - file.close(); - - // System.out.println("Serialization worked"); - }catch(IOException ex) { - - System.out.println("IOException is caught"); - } - - - - } public static ArrayList getStudents(){ @@ -158,6 +152,10 @@ public static ArrayList getDepartments(){ return departmentsList; } + public static boolean initializedList() { + return initializedList; + } + public static void assignStudsToDeps() { for(Student student: students) { for(int i = 0; i < departmentsList.size(); i++) diff --git a/src/LogRegCheck.java b/src/LogRegCheck.java index a266f2e..fd94b80 100644 --- a/src/LogRegCheck.java +++ b/src/LogRegCheck.java @@ -3,7 +3,7 @@ public class LogRegCheck { public static Student checkUsername(String aUsername) { //We need a initializedList variable in Central Registry - if ( !CentralRegistry.initializedList ) + if ( !CentralRegistry.initializedList() ) return null; for(Student student: CentralRegistry.getStudents())