Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Romputer committed Jun 12, 2019
1 parent c7f4573 commit 817a6c2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 30 deletions.
56 changes: 27 additions & 29 deletions src/CentralRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class CentralRegistry

private static ArrayList<Student> students;

public static boolean initializedList = false;
private static boolean initializedList = false;


@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -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() {

Expand All @@ -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<Student> getStudents(){

Expand Down Expand Up @@ -158,6 +152,10 @@ public static ArrayList<Department> 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++)
Expand Down
2 changes: 1 addition & 1 deletion src/LogRegCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 817a6c2

Please sign in to comment.