From fa3193ee4aa2daa4e6b859f7c9d6629db311b964 Mon Sep 17 00:00:00 2001 From: Tobias Herbert Date: Tue, 6 Feb 2024 20:11:05 +0100 Subject: [PATCH 1/3] Added findProfessorById Method to Administration Class --- src/main/java/org/example/Administration.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/org/example/Administration.java b/src/main/java/org/example/Administration.java index d7cd3bf..1c00bc8 100644 --- a/src/main/java/org/example/Administration.java +++ b/src/main/java/org/example/Administration.java @@ -49,6 +49,18 @@ public class Administration { admins.add(admin); } + public Professor findProfessorById(String professorId) + { + for(Professor professor :professors) + { + if(professor.getProfessorID().equals(professorId)) + { + return professor; + } + } + + return null; + } From 8cec839c4cfac1b213f1e4acee10b46aff6c873d Mon Sep 17 00:00:00 2001 From: Tobias Herbert Date: Tue, 6 Feb 2024 20:13:56 +0100 Subject: [PATCH 2/3] Refactoring: Administration Class --- src/main/java/org/example/Administration.java | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/example/Administration.java b/src/main/java/org/example/Administration.java index 1c00bc8..ba383cb 100644 --- a/src/main/java/org/example/Administration.java +++ b/src/main/java/org/example/Administration.java @@ -20,7 +20,7 @@ public class Administration { { if(professor.getProfessorID().equals(professorID)){ professors.remove(professor); - return true; //Course found and removed + return true; } } @@ -30,12 +30,23 @@ public class Administration { { professors.add(professor); } + public Professor findProfessorById(String professorId) + { + for(Professor professor :professors) + { + if(professor.getProfessorID().equals(professorId)) + { + return professor; + } + } - public boolean deleteAdmin(String AdminID) + return null; + } + public boolean deleteAdmin(String adminID) { for(Admin admin : admins ) { - if(admin.getId().equals(AdminID)){ + if(admin.getId().equals(adminID)){ admins.remove(admin); return true; //Course found and removed } @@ -43,24 +54,12 @@ public class Administration { return false; } - public void addAdmin(Admin admin) { admins.add(admin); } - public Professor findProfessorById(String professorId) - { - for(Professor professor :professors) - { - if(professor.getProfessorID().equals(professorId)) - { - return professor; - } - } - return null; - } From d369184d49814f8e65b9f8f26d4ded84d77367ad Mon Sep 17 00:00:00 2001 From: Tobias Herbert Date: Tue, 6 Feb 2024 20:23:13 +0100 Subject: [PATCH 3/3] Documentation: Administration Class --- src/main/java/org/example/Administration.java | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/example/Administration.java b/src/main/java/org/example/Administration.java index ba383cb..706fc3e 100644 --- a/src/main/java/org/example/Administration.java +++ b/src/main/java/org/example/Administration.java @@ -4,16 +4,26 @@ import java.util.ArrayList; import java.util.List; public class Administration { + /** + * Instance Variables + */ private List professors; private List admins; + /** + * Constructor + */ public Administration() { this.professors = new ArrayList<>(); this.admins = new ArrayList<>(); } - + /** + * + * @param professorID the id of the professor you want to be deleted from the system + * @return the value of the return statement expresses whether the professor has been deleted + */ public boolean deleteProfessor(String professorID) { for(Professor professor : professors) @@ -26,10 +36,21 @@ public class Administration { return false; } + + /** + * + * @param professor the professor you want to add to the system + */ public void addProfessor(Professor professor) { professors.add(professor); } + + /** + * + * @param professorId the id of the professor you want to look for + * @return the value of the return statement expresses whether the professor has been found and if so returns this professor + */ public Professor findProfessorById(String professorId) { for(Professor professor :professors) @@ -42,6 +63,12 @@ public class Administration { return null; } + + /** + * + * @param adminID the id of the admin you want to be deleted from the system + * @return the value of the return statement expresses whether the admin has been deleted + */ public boolean deleteAdmin(String adminID) { for(Admin admin : admins ) @@ -54,6 +81,11 @@ public class Administration { return false; } + + /** + * + * @param admin the admin you want to add to the system + */ public void addAdmin(Admin admin) { admins.add(admin);