|
|
@ -2,6 +2,7 @@ package org.example; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Scanner; |
|
|
|
|
|
|
|
public class Administration { |
|
|
|
/** |
|
|
@ -10,6 +11,7 @@ public class Administration { |
|
|
|
private List<Professor> professors; |
|
|
|
private List<Admin> admins; |
|
|
|
private List<Student> students; |
|
|
|
Scanner scanner = new Scanner(System.in); |
|
|
|
|
|
|
|
/** |
|
|
|
* Constructor |
|
|
@ -158,6 +160,54 @@ public class Administration { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
public void registerUser() |
|
|
|
{ |
|
|
|
String UserId = null; |
|
|
|
String UserName = null; |
|
|
|
|
|
|
|
System.out.println("Enter the type of user (1-Student, 2-Admin, 3-Professor): "); |
|
|
|
int userType = scanner.nextInt(); |
|
|
|
|
|
|
|
|
|
|
|
boolean correctData = false; |
|
|
|
while(!correctData) |
|
|
|
{ |
|
|
|
System.out.println("Enter the User Details!"); |
|
|
|
System.out.println("Name: "); |
|
|
|
UserName = scanner.next(); |
|
|
|
System.out.println("ID: "); |
|
|
|
UserId = scanner.next(); |
|
|
|
|
|
|
|
if(findProfessorById(UserId) != null || findAdminById(UserId) != null || findStudentById(UserId) != null) |
|
|
|
{ |
|
|
|
System.out.println("Please enter an ID which is not being used!"); |
|
|
|
correctData = false; |
|
|
|
} |
|
|
|
else if(findProfessorById(UserId) == null || findAdminById(UserId) == null || findStudentById(UserId) == null) |
|
|
|
{ |
|
|
|
System.out.println("The Id has not been used already!"); |
|
|
|
correctData = true; |
|
|
|
} |
|
|
|
|
|
|
|
switch (userType) |
|
|
|
{ |
|
|
|
case 1: |
|
|
|
Student student = new Student(UserName, UserId, "Student"); |
|
|
|
addStudents(student); |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
Admin admin = new Admin(UserName, UserId, "Admin"); |
|
|
|
addAdmin(admin); |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
Professor professor = new Professor(UserId, UserName, "Professor"); |
|
|
|
addProfessor(professor); |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|