Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 0 additions & 178 deletions Java files/JavaUserCommandLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -789,185 +789,7 @@ else if(FirstOption=="Login"){
break;
}
processCommand(Counter);

}

}
}
//Back Option Manager,manages the back process back when selected by the user.
public void back(int Counter) {
Counter=0;
//System.out.println(" Clear Screen");
processCommand(Counter);
}

//handles submissions to server
public void submitDetails(int Counter,String FirstOption,String SecondOption,String ID,String SchoolNumber,String FirstName,String LastName,String UserName,String DOB,String Email,String Password,byte[] ImageData,String ImagePath) {

//Declaring Formatting variables
String Cyan = "\u001B[36m";
String Green = "\u001B[32m";
String Restore = "\u001b[0m";
String Red = "\u001B[31m";
String Italic = "\033[3m";
String Yellow="\u001B[33m";


String Command;
if (Counter == 1) {
System.err.print(" ONE MORE TRIAL REMAINING!......\n\n");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.print("\n+-----Enter "+Yellow+"[ submit ] "+Restore+"to submit-----+\n ");

System.out.print(Green+Italic);
Command = Input.nextLine();
System.out.print(Restore);

//checking the input whether its "submit" or "invalid input"
switch (Command) {
case "submit":
System.out.print("+-----Are you sure to Submit"+Yellow+"[yes/no]"+Restore+"-+\n ");

System.out.print(Green+Italic);
Command = Input.nextLine();
System.out.print(Restore);

//checks whether reply is "Yes, submit" or " not submit"
if (Command.equals("yes")) {

System.out.print("\n" + Green + "Submitting to server.");

//Animates the dots to imitate loading
for (int i = 0; i < 5; i++) {
try {
Thread.sleep(500);
System.out.print(Green + ".");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.print(Restore);
try {
//setting up Client-server connection
String FeedBack;
AttributesTobeSubmited ATS = new AttributesTobeSubmited(FirstOption, SecondOption, ID, SchoolNumber, FirstName, LastName, UserName, DOB, Email, Password,ImageData,ImagePath);
this.socket = new Socket("localhost", 1111);
this.OOS = new ObjectOutputStream(socket.getOutputStream());
this.OIS = new ObjectInputStream(socket.getInputStream());
OOS.writeObject(ATS);
OOS.flush();

//evaluating server feedback after submission and generating respective responses to client
FeedBack = (String) OIS.readObject();

//if User submitted registration form
if (ATS.FirstOption.equalsIgnoreCase("Register")) {
if (FeedBack.equalsIgnoreCase("School Number Does Not Exist")) {
System.err.print("\n------The School Number is Incorrect!-----\n RE-ENTER DETAILS");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}

//Prompting the user to re-enter credentials after error Message
Counter = 0;
user.register(ATS.SecondOption, Counter, ATS.FirstOption);
} else if (FeedBack.equalsIgnoreCase("Once Rejected")) {
System.err.println("\n-----Your ID was once rejected on this Particular School!-----" +
"\n You may Re-load and Register on your Current School which is Verified in our System" +
"\n Thank you!");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
break;
} else if (FeedBack.equalsIgnoreCase("Recognised") || FeedBack.equalsIgnoreCase("Registration Pending")) {
System.out.println("\n" + Cyan + " Your Registration is Pending!\n You will receive a confirmation E-mail.\n THANK YOU! ");
System.out.print(Restore);
break;
} else if (FeedBack.equalsIgnoreCase("Not Recognised")) {
System.err.println("\n-----Your Representative ID does not Match Any Record!-----\n RE-ENTER DETAILS");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}

//Prompting the user to re-enter credentials after error Message
Counter = 0;
user.register(ATS.SecondOption, Counter, ATS.FirstOption);

}
}

// if it was User login submission
else {
if (FeedBack.equalsIgnoreCase("Invalid Credentials")) {
System.err.println("\n-----Invalid UserName Or Password!-----\n RE-ENTER DETAILS");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}

//Prompting the user to re-enter credentials after error Message
Counter = 0;
user.login(ATS.SecondOption, Counter, ATS.FirstOption);
} else {
System.out.println("\n" + Cyan + " Login SuccessFull!\n");
System.out.print(Restore);

//executes afterloginmanager if it was successful user registration. it will evaluate if it was a schoolrep or a participant(pupil)
Counter = 0;
afterLoginManager(ATS.SecondOption, Counter, this.socket, this.OIS,this.OOS);
break;
}
break;
}
} catch (UnknownHostException e) {
e.printStackTrace();
break;
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}

//if it was a no submission
else if (Command.equals("no")) {
System.err.print("-----Submission declined!-----");
break;
} else {
System.err.println("-----INVALID OPTION, SUBMISSION CLOSED!-----\n You may access this System later.\n Thank you!");
break;
}
break;
default:
try {
Counter++;
System.err.println("-----Invalid Entry!-----");
Thread.sleep(1000);
if (Counter == 2) {
System.err.println(" Exceeded maximum trials!!\n Try again Later, thank you. ");
break;
}
submitDetails(Counter, FirstOption, SecondOption, ID, SchoolNumber, FirstName, LastName, UserName, DOB, Email, Password,ImageData,ImagePath);
break;
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}




//ATS class