Skip to content

Commit

Permalink
Made FileUser's getAccounts() method static. Minor change to StudentU…
Browse files Browse the repository at this point in the history
…ser based on Julie's feedback.
  • Loading branch information
CC-3636 committed Dec 2, 2022
1 parent f6a7ca6 commit ba898cf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
Binary file modified src/main/java/data/users.ser
Binary file not shown.
2 changes: 1 addition & 1 deletion src/main/java/entities/StudentUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public ArrayList<String> getCourses() {
}

public void addCourse(String course) {
this.toDoList.add(course);
this.courses.add(course);
}

public void setCourses(ArrayList<String> c) { this.courses = c; }
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/screens/login_registration/FileUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

public class FileUser implements UserRegGateway, LoginGateway, LogoutGateway {

private final HashMap<String, UserRegSaveRequest> accounts;
// private final HashMap<String, UserRegSaveRequest> accounts;
private static HashMap<String, UserRegSaveRequest> accounts;

private final String filePath;

Expand All @@ -29,9 +30,11 @@ public FileUser(String path) throws IOException, ClassNotFoundException {
// and reads the existing file if it does exist

if (Files.exists(Path.of(path))) {
this.accounts = readFile();
// this.accounts = readFile();
accounts = readFile();
} else {
this.accounts = new HashMap<String, UserRegSaveRequest>();
// this.accounts = new HashMap<String, UserRegSaveRequest>();
accounts = new HashMap<String, UserRegSaveRequest>();
save();
}

Expand Down Expand Up @@ -91,7 +94,8 @@ public String passOf(String name) {
}

public Map<String, UserRegSaveRequest> getAccounts() {
return this.accounts;
// return this.accounts;
return accounts;
}

}
Binary file modified src/test/java/data/userstest.ser
Binary file not shown.

0 comments on commit ba898cf

Please sign in to comment.