Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package donorschoose.org;
- import java.util.Scanner;
- import ThankyouPackage.ThankyouPackage;
- import Project.*;
- import Member.*;
- import Member.TeacherList;
- /**
- * This is the main class it tests all the behaviors of the implemented classes
- * @version 1.0
- * @author Mounir/ Saad
- * @exception this class throws EnumException which occurs when user inputs invalid enum type, and PassException when user fails to Authenticate
- */
- public class DonorsApp {
- static int index;
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- UserList users = new UserList();
- TeacherList teachers = new TeacherList();
- int choice;
- int flag = 0;
- int flag2 = 0;
- int initialpts =0;
- do{
- System.out.println("----------------------------------------------");
- System.out.println(" Hello user. Please choose an option");
- System.out.println(" 1. Register");
- System.out.println(" 2. Exit");
- System.out.println("---------------------------------------------");
- System.out.print(" Choice:");
- choice = input.nextInt();
- switch (choice){
- case 1:
- System.out.println("---------------------------------------------");
- System.out.println(" Please choose your option for Registration");
- System.out.println(" 1. Register as a Teacher");
- System.out.println(" 2. Register as a User ");
- System.out.println("---------------------------------------------");
- System.out.print(" Choice:");
- choice = input.nextInt();
- switch (choice){
- case 1:
- System.out.println(" Registering as a Teacher !");
- System.out.println(" Enter Username");
- String t_username = input.next();
- System.out.println(" Enter Password");
- String t_pswd = input.next();
- System.out.println(" Enter First Name");
- String t_f_name = input.next();
- System.out.println(" Enter Last Name");
- String t_l_name = input.next();
- System.out.println(" Enter Email ");
- String t_mail = input.next();
- String t_position= "huhu";
- int t_pts=initialpts;
- Teacher t1 = new Teacher(t_username, t_pswd, t_f_name, t_l_name, t_mail, t_position, t_pts);
- teachers.addTeacher(t1);
- break;// Break registration as a teacher
- case 2:
- System.out.println(" Registering as a User !");
- System.out.println(" Enter Username");
- String u_username = input.next();
- System.out.println(" Enter Password");
- String u_pswd = input.next();
- System.out.println(" Enter First Name");
- String u_f_name = input.next();
- System.out.println(" Enter Last Name");
- String u_l_name = input.next();
- System.out.println(" Enter Email ");
- String u_mail = input.next();
- User u1 =new User(u_username, u_pswd, u_f_name, u_l_name, u_mail);
- users.addUser(u1);
- break;//Break registration as a user
- }
- flag =1;
- break;// Break registration
- case 2:
- flag=1;
- break;// exit the program
- default:
- System.out.println("Invalid choice! Please Try Again!");
- break;
- }
- }while(flag!=1);
- //First time run handeled
- flag = choice = 0;
- do{
- System.out.println("---------------------------------------");
- System.out.println(" 1. Login");
- System.out.println(" 2. Register");
- System.out.println(" 3. Exit");
- System.out.println("---------------------------------------");
- System.out.print(" Choice:");
- choice = input.nextInt();
- switch (choice){
- case 1:
- String user;
- String pswd;
- do{
- System.out.print("AUTHENTICATION !");
- System.out.print("Enter UserName");
- user = input.next();
- System.out.print("Enter Password: ");
- pswd = input.next();
- index = users.search(user);
- if (index == -1)
- System.out.println("Login Error!");
- }while( index == -1);
- try{
- if(teachers.getTeacher(index).Authenticate(user, pswd)){
- System.out.println("Authentification Successful!\n\n");
- }
- else
- throw new PassException();
- }catch(PassException ex){
- System.out.println(ex.getMessage());
- }
- break; //Break case Login
- case 2:
- System.out.println("---------------------------------------------");
- System.out.println(" Please choose your option for Registration");
- System.out.println(" 1. Register as a Teacher");
- System.out.println(" 2. Register as a User ");
- System.out.println("---------------------------------------------");
- System.out.print(" Choice:");
- choice = input.nextInt();
- switch (choice){
- case 1:
- System.out.println(" Registering as a Teacher !");
- System.out.println(" Enter Username");
- String t_username = input.next();
- System.out.println(" Enter Password");
- String t_pswd = input.next();
- System.out.println(" Enter First Name");
- String t_f_name = input.next();
- System.out.println(" Enter Last Name");
- String t_l_name = input.next();
- System.out.println(" Enter Email ");
- String t_mail = input.next();
- String t_position= "huhu";
- int t_pts=initialpts;
- Teacher t1 = new Teacher(t_username, t_pswd, t_f_name, t_l_name, t_mail, t_position, t_pts);
- teachers.addTeacher(t1);
- break;// Break registration as a teacher
- case 2:
- System.out.println(" Registering as a User !");
- System.out.println(" Enter Username");
- String u_username = input.next();
- System.out.println(" Enter Password");
- String u_pswd = input.next();
- System.out.println(" Enter First Name");
- String u_f_name = input.next();
- System.out.println(" Enter Last Name");
- String u_l_name = input.next();
- System.out.println(" Enter Email ");
- String u_mail = input.next();
- User u1 =new User(u_username, u_pswd, u_f_name, u_l_name, u_mail);
- users.addUser(u1);
- break;//Break registration as a user
- }
- flag =1;
- break; //Break case Register
- case 3:
- flag =1;
- break;// Exit
- default:
- System.out.println("Invalid choice! Please Try Again!");
- break;
- }
- /*
- * Ha fin Wselt le rest tkharbik pour le moment
- * */
- System.out.println("---------------------------------");
- System.out.println("Menu");
- System.out.println("-------------Choose a scenario--------------------");
- System.out.println("Teacher Scenarios: \n");
- System.out.println("---------------------------------");
- System.out.println("\t *1. Register to become a teacher ");
- System.out.println("\t *2. Login");
- System.out.println("\t *3. Modify profile and personal information");
- System.out.println("\t *4. Create a project, add the different details and the material list");
- System.out.println("\t *5. View donations");
- System.out.println("\t *6. Post a thank you package");
- System.out.println("---------------------------------");
- System.out.println("User scenarios: \n");
- System.out.println("---------------------------------");
- System.out.println("\t *7. Register as a normal user");
- System.out.println("\t *8. Login");
- System.out.println("\t *9. Browse for projects");
- System.out.println("\t *10. Add projects to the whishlist");
- System.out.println("\t *11. Choose a project, Post a message");
- System.out.println("\t *12. Choose a project from the whishlist, Donate to the project");
- System.out.println("\t *13. Display the donation history");
- System.out.println("\t *14. EXIT");
- System.out.println("---------------------------------");
- choice = input.nextInt();
- switch (choice){
- case 1:
- }
- }while(flag==0);
- }
- }
Add Comment
Please, Sign In to add comment