Skip to content

Commit

Permalink
Admin Java doc done
Browse files Browse the repository at this point in the history
  • Loading branch information
Tribby-221 committed Nov 25, 2020
1 parent e86c581 commit c3c83be
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 4 deletions.
31 changes: 31 additions & 0 deletions STARS/Admin.java
Original file line number Diff line number Diff line change
@@ -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){}


Expand Down
17 changes: 16 additions & 1 deletion STARS/AdminInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<AccessPeriod> accessPeriodList) throws IOException, ParseException {
String num = "";
Console console = System.console();
Expand Down
62 changes: 59 additions & 3 deletions STARS/AdminManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Student> studentList, String value);
}

/**
* creating new student accounts
* @param fullStudentList is the entire list of student accounts
*/
public void addStudent(List<Student> fullStudentList) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter Student's Matriculation Number");
Expand Down Expand Up @@ -79,6 +92,12 @@ public void addStudent(List<Student> 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<Course> courseList,List<Lesson> lessonList) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter Course Index Number");
Expand Down Expand Up @@ -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<Course> courseList,int courseNo){
List<Course> tempCourse =courseList.stream().filter(x -> x.getIndex()==courseNo).collect(Collectors.toList());
if(tempCourse.isEmpty())
Expand All @@ -195,10 +220,22 @@ private boolean checkExistingCourse(List<Course> 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<Student> removeStudent(List<Student> 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<Student> fullStudentList,String matricNo){
List<Student> tempStudent =fullStudentList.stream().filter(x -> x.getMatid().equals(matricNo)).collect(Collectors.toList());
System.out.println(tempStudent);
Expand All @@ -209,7 +246,12 @@ private boolean checkExistingStudent(List<Student> 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 -> {
Expand All @@ -232,7 +274,12 @@ private boolean checkExistingStudent(List<Student> 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<Course> studentCourse = i.getCourse();
Expand All @@ -253,6 +300,11 @@ private boolean checkExistingStudent(List<Student> 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");
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c3c83be

Please sign in to comment.