From c3c83be6f1d5970509b6351536eb5d6738c53de2 Mon Sep 17 00:00:00 2001 From: Docchopper221 Date: Wed, 25 Nov 2020 09:47:52 +0800 Subject: [PATCH] Admin Java doc done --- STARS/Admin.java | 31 ++++++++++++++++++++ STARS/AdminInterface.java | 17 ++++++++++- STARS/AdminManager.java | 62 +++++++++++++++++++++++++++++++++++++-- 3 files changed, 106 insertions(+), 4 deletions(-) diff --git a/STARS/Admin.java b/STARS/Admin.java index ef7a31e..bb9adda 100644 --- a/STARS/Admin.java +++ b/STARS/Admin.java @@ -1,17 +1,48 @@ +/** + * Admin class that implements users + * and object that is admin account + * @author Team Stars + * @version 1.0 + * @since 2020 + */ public class Admin implements User{ + /** + * Username as the unique value + * password as the password for admin + */ String username, password; + + /** + * Admin constructor + * @param username as the username for admin account + * @param password as the password for admin account + */ public Admin(String username, String password){ this.username = username; this.password = password; } + /** + * return the username of admin object + */ public String getUsername(){ return username; } + /** + * return the password of the admin object + */ public String getPassword(){ return password; } + /** + * setting the username of admin object' + * @param username as the new username + */ @Override public void setUsername(String username){} + /** + * setting the password of admin object + * @param password as the new password + */ public void setPassword(String password){} diff --git a/STARS/AdminInterface.java b/STARS/AdminInterface.java index bc62fb4..2301eaf 100644 --- a/STARS/AdminInterface.java +++ b/STARS/AdminInterface.java @@ -6,9 +6,24 @@ import java.text.ParseException; import java.util.Date; +/** + * This is the admin UI/UX + * prints the menu and also checks for valid inputs + * @author Team Stars + * @version 1.0 + * @since 2020 + */ public class AdminInterface { + /** + * scanner for taking in user input + */ Scanner sc = new Scanner(System.in); - + /** + * the function that prints the menu and handle input checks + * @param accessPeriodList is the list of available access periods for student + * @throws IOException is to check for database load fails + * @throws ParseException is to check for casting/parsing fails + */ public void AdminMenuLogic(List accessPeriodList) throws IOException, ParseException { String num = ""; Console console = System.console(); diff --git a/STARS/AdminManager.java b/STARS/AdminManager.java index 242ecd6..510bb43 100644 --- a/STARS/AdminManager.java +++ b/STARS/AdminManager.java @@ -6,11 +6,24 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.regex.Matcher; + +/** + * This is the admin manager where all the admin functions are written + * @author Team Stars + * @version 1.0 + * @since 2020 + */ public class AdminManager { + /** + * an interface for flitering studentlist + */ interface PrintStudentList { public void Invoke(List studentList, String value); } - + /** + * creating new student accounts + * @param fullStudentList is the entire list of student accounts + */ public void addStudent(List fullStudentList) { Scanner sc = new Scanner(System.in); System.out.println("Enter Student's Matriculation Number"); @@ -79,6 +92,12 @@ public void addStudent(List fullStudentList) { System.out.println("Student already exist in records"); } } + + /** + * adding a new course to the system + * @param courseList the entire list of courses + * @param lessonList the entire list of lessons + */ public void addCourse(List courseList,List lessonList) { Scanner sc = new Scanner(System.in); System.out.println("Enter Course Index Number"); @@ -185,6 +204,12 @@ else if( endtime<=starttime) System.out.println("Course already exist in records"); } } + /** + * a check for adding course to make sure there is no duplicated index + * @param courseList the entire course list + * @param courseNo the index to be created + * @return a boolean. False when it is not existed. True when it exist. + */ private boolean checkExistingCourse(List courseList,int courseNo){ List tempCourse =courseList.stream().filter(x -> x.getIndex()==courseNo).collect(Collectors.toList()); if(tempCourse.isEmpty()) @@ -195,10 +220,22 @@ private boolean checkExistingCourse(List courseList,int courseNo){ return true; } + /** + * Deleting student account + * @param fullStudentList The entire student list + * @param matricNo the matric number of account to be deleted + * @return the studentlist and is found + */ public List removeStudent(List fullStudentList, String matricNo) { return fullStudentList.stream().filter(x -> x.getMatid().equals(matricNo)).collect(Collectors.toList()); } + /** + * a check for creating student to make sure there is no duplicated matric id + * @param fullStudentList the entire list of student + * @param matricNo the matric id to be created + * @return a boolean. False when it is not existed. True when it exist. + */ private boolean checkExistingStudent(List fullStudentList,String matricNo){ List tempStudent =fullStudentList.stream().filter(x -> x.getMatid().equals(matricNo)).collect(Collectors.toList()); System.out.println(tempStudent); @@ -209,7 +246,12 @@ private boolean checkExistingStudent(List fullStudentList,String matric } return true; } - + /** + * rewrite from interface + * this will print all the student that have registered for the course index + * @param fullStudentList + * @param IndexInString + */ PrintStudentList printStudentfromIndex = (fullStudentList, indexInString) -> { int index = Integer.parseInt(indexInString); fullStudentList.stream().forEach(i -> { @@ -232,7 +274,12 @@ private boolean checkExistingStudent(List fullStudentList,String matric // } // } }; - + /** + * rewrite from interface + * this will print all the student that have registered for the course + * @param fullStudentList + * @param CourseCode + */ PrintStudentList printStudentFromCourse = (fullStudentList, courseCode) -> { fullStudentList.stream().forEach(i -> { List studentCourse = i.getCourse(); @@ -253,6 +300,11 @@ private boolean checkExistingStudent(List fullStudentList,String matric // } // } }; + + /** + * Entering a new access period + * @return null when exception or invalid input + */ public Date InputDateTime(){ Scanner sc = new Scanner(System.in); System.out.println("\nEnter Day i.e 01"); @@ -331,6 +383,10 @@ public Date InputDateTime(){ } //regex to validate email address pattern private static final String regex = "^[a-zA-Z0-9_+&*-]+(?:\\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,7}$"; + /** + * checking valid email + * @param email is the creating new student email + */ public static boolean isValidEmailAddress(String email) { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(email);