|
@ -207,8 +207,8 @@ public class Administration { |
|
|
{ |
|
|
{ |
|
|
//Instance variables |
|
|
//Instance variables |
|
|
|
|
|
|
|
|
String UserId = null; |
|
|
|
|
|
String UserName = null; |
|
|
|
|
|
|
|
|
String userId = null; |
|
|
|
|
|
String userName = null; |
|
|
|
|
|
|
|
|
System.out.print("Enter the type of user (1-Student, 2-Admin, 3-Professor): "); |
|
|
System.out.print("Enter the type of user (1-Student, 2-Admin, 3-Professor): "); |
|
|
int userType = scanner.nextInt(); |
|
|
int userType = scanner.nextInt(); |
|
@ -219,28 +219,28 @@ public class Administration { |
|
|
{ |
|
|
{ |
|
|
System.out.println("Enter the User Details!"); |
|
|
System.out.println("Enter the User Details!"); |
|
|
System.out.print("Name: "); |
|
|
System.out.print("Name: "); |
|
|
UserName = scanner.next(); |
|
|
|
|
|
|
|
|
userName = scanner.next(); |
|
|
System.out.print("ID: "); |
|
|
System.out.print("ID: "); |
|
|
UserId = scanner.next(); |
|
|
|
|
|
|
|
|
userId = scanner.next(); |
|
|
|
|
|
|
|
|
//Checks if the entered id is already being used |
|
|
//Checks if the entered id is already being used |
|
|
if(findProfessorById(UserId) != null || findAdminById(UserId) != null || findStudentById(UserId) != null) |
|
|
|
|
|
|
|
|
if(findProfessorById(userId) != null || findAdminById(userId) != null || findStudentById(userId) != null) |
|
|
{ |
|
|
{ |
|
|
//the entered id is used |
|
|
//the entered id is used |
|
|
System.out.println("Please enter an ID which is not being used!"); |
|
|
System.out.println("Please enter an ID which is not being used!"); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
else if(findProfessorById(UserId) == null || findAdminById(UserId) == null || findStudentById(UserId) == null) |
|
|
|
|
|
|
|
|
else if(findProfessorById(userId) == null || findAdminById(userId) == null || findStudentById(userId) == null) |
|
|
{ |
|
|
{ |
|
|
//the entered id is not used |
|
|
//the entered id is not used |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!rightPrefix(UserId, userType)) |
|
|
|
|
|
|
|
|
if(!rightPrefix(userId, userType)) |
|
|
{ |
|
|
{ |
|
|
//the prefix is wrong |
|
|
//the prefix is wrong |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
else if(!isNumber(UserId)) |
|
|
|
|
|
|
|
|
else if(!isNumber(userId)) |
|
|
{ |
|
|
{ |
|
|
//the substring does not contain only digits |
|
|
//the substring does not contain only digits |
|
|
System.out.println("Every character besides the first one need to be digits"); |
|
|
System.out.println("Every character besides the first one need to be digits"); |
|
@ -258,15 +258,15 @@ public class Administration { |
|
|
switch (userType) |
|
|
switch (userType) |
|
|
{ |
|
|
{ |
|
|
case 1: //Student |
|
|
case 1: //Student |
|
|
Student student = new Student(UserName, UserId, "Student"); |
|
|
|
|
|
|
|
|
Student student = new Student(userName, userId, "Student"); |
|
|
addStudents(student); |
|
|
addStudents(student); |
|
|
break; |
|
|
break; |
|
|
case 2: //Admin |
|
|
case 2: //Admin |
|
|
Admin admin = new Admin(UserName, UserId, "Admin"); |
|
|
|
|
|
|
|
|
Admin admin = new Admin(userName, userId, "Admin"); |
|
|
addAdmin(admin); |
|
|
addAdmin(admin); |
|
|
break; |
|
|
break; |
|
|
case 3: //Professor |
|
|
case 3: //Professor |
|
|
Professor professor = new Professor(UserId, UserName, "Professor"); |
|
|
|
|
|
|
|
|
Professor professor = new Professor(userId, userName, "Professor"); |
|
|
addProfessor(professor); |
|
|
addProfessor(professor); |
|
|
default: //Error |
|
|
default: //Error |
|
|
break; |
|
|
break; |
|
|