From cdf2f0daf49b732a77771b5840216dd5b8a19f52 Mon Sep 17 00:00:00 2001 From: fdai7887 Date: Tue, 6 Feb 2024 21:01:52 +0100 Subject: [PATCH] refactored: Administration class --- src/main/java/org/example/Administration.java | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/main/java/org/example/Administration.java b/src/main/java/org/example/Administration.java index 4f157ba..6acd8e1 100644 --- a/src/main/java/org/example/Administration.java +++ b/src/main/java/org/example/Administration.java @@ -67,31 +67,9 @@ public class Administration { return null; } - public Admin findAdminById(String adminId) - { - for(Admin admin :admins) - { - if(admin.getId().equals(adminId)) - { - return admin; - } - } - return null; - } - public Student findStudentById(String StudentId) - { - for(Student student :students) - { - if(student.getId().equals(StudentId)) - { - return student; - } - } - return null; - } /** * * @param adminID the id of the admin you want to be deleted from the system @@ -119,9 +97,22 @@ public class Administration { admins.add(admin); } - public boolean deleteStudents(String StudentID){ + public Admin findAdminById(String adminId) + { + for(Admin admin :admins) + { + if(admin.getId().equals(adminId)) + { + return admin; + } + } + + return null; + } + + public boolean deleteStudents(String studentID){ for(Student student : students){ - if(student.getId().equals(StudentID)){ + if(student.getId().equals(studentID)){ students.remove(student); return true; } @@ -129,12 +120,23 @@ public class Administration { return false; } -public void addStudents(Student student){ + public void addStudents(Student student){ students.add(student); -} + } + public Student findStudentById(String studentId) + { + for(Student student :students) + { + if(student.getId().equals(studentId)) + { + return student; + } + } + return null; + } }