-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainSystem.java
More file actions
114 lines (104 loc) · 3.14 KB
/
MainSystem.java
File metadata and controls
114 lines (104 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package com.ourteamnotification;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;
public class MainSystem {
public static Notification notification;
public static User normalUser;
public static User admin;
public static UserChecker checker;
public static DataBase database = new UsersDataBase();//
// database.addUser();
public char input;
public String email,password,name;
public void defaultData() {
// admin = new Admin("dev","dev","1234");//the fake mail will be added later
// database.addUser(admin);
database.addUser("justin","[email protected]","A123A123"); //the
}
public Scanner scan= new Scanner(System.in);
public void execute() {
System.out.println("1- Log in.\n2- Sign up.");
normalUser = new NormalUser();
input = scan.next().charAt(0);
switch(input) {
case '1' :
{
Scanner scan = new Scanner (System.in);
// UserChecker checker= new UserChecker();
System.out.print("email : "); //
email = scan.nextLine();
System.out.print("password : "); //
password = scan.nextLine();
Login login = new Login();
if (login.Log_in(name, email, password)) {
normalUser.setEmail(email);
normalUser.setPassword(password);
normalUser.setName(name);
System.out.println("Welcome " + normalUser.getName());
}
if (email.equals("[email protected]") && password.equals("ourteammembers2020@@")) {
admin = new Admin();
admin.setName("admin");
int menuNumber;
while(true) {
admin.menu();
menuNumber = scan.nextInt();
switch(menuNumber) {
case 1 :
((Admin) admin).create("new notification");
break;
case 2 :
((Admin) admin).read();
break;
case 3:
((Admin) admin).delete();
break;
case 4 :
((Admin) admin).update();
break;
case 5:
((Admin) admin).getStatistics();
break;
case 6:
System.out.println("logged out");
System.exit(0);
break;
default:
System.out.println("Enter a valid number.");
break;
}
}
}
else System.out.println("not Exist user try to sign up");
break;
}
case '2': // sign up
{
String n = scan.nextLine();
System.out.println("Name : ");
name = scan.nextLine();
normalUser.setName(name);
System.out.println("email : ");
email = scan.nextLine();
normalUser.setEmail(email);
System.out.println("password : ");
password = scan.nextLine();
normalUser.setPassword(password);
SignUp register = new SignUp(normalUser);
if (register!=null) {
notification = new RegisterNotification();
notification.setNotificationContent("Thanks to Register With us.");
MailSender sender = new MailSender("[email protected]","ourteammembers2020@@",normalUser.getEmail(),notification);
}
break;
}
}
//
}
public static void main(String[] args) throws IOException {
MainSystem system = new MainSystem();
system.defaultData();
system.execute();
}
}