-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
75 lines (72 loc) · 2.95 KB
/
Main.java
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
package com.accenture.itfactory.base.FilmApplication;
import java.nio.file.FileSystems;
import java.util.*;
public class Main {
public static void main(String[] args) {
// write your code here
Login loginPage = new Login();
UserPage userPage = new UserPage();
boolean correctLogin = false;
String abspath = FileSystems.getDefault().getPath(".").toAbsolutePath().toString();
String path = abspath + "\\FilmDatabase.xml";
System.out.println("Choose an option please: ");
System.out.println("1 - Login as User\n 2 - Login as Admin\n 3 - Sign Up\n");
Scanner in = new Scanner(System.in);
int choice = in.nextInt();
if(choice == 1){ //Login as User
System.out.println("Enter login:");
String enteredLogin = in.nextLine();
System.out.println("Enter password");
String enteredPassword = in.nextLine();
try {
correctLogin = loginPage.checkLogin(enteredLogin, enteredPassword);
}
catch (Exception e){
e.printStackTrace();
}
}
if(choice == 2){ //Login as Admin
System.out.println("Enter login:");
String enteredLogin = in.nextLine();
System.out.println("Enter password");
String enteredPassword = in.nextLine();
correctLogin = loginPage.isAdmin(enteredLogin,enteredPassword);
}
if(choice == 3){ //Sign Up
System.out.println("Enter name:");
String enteredName = in.nextLine();
System.out.println("Enter login:");
String enteredLogin = in.nextLine();
System.out.println("Enter password");
String enteredPassword = in.nextLine();
loginPage.addUser(enteredName,enteredLogin,enteredPassword);
try {
correctLogin = loginPage.checkLogin(enteredLogin, enteredPassword);
}
catch (Exception e){
e.printStackTrace();
}
}
if(correctLogin){
System.out.println("1- View films\n 2- Search films\n 3- Add review");
choice = in.nextInt();
if(choice == 1){ //view films
userPage.viewFilms();
}
if(choice == 2){ //Search films
System.out.println("Enter any film parameter: \n");
String input = in.nextLine();
userPage.search(input);
}
if(choice == 3){ //Add review
System.out.println("Enter film name and then review: \n");
String input = in.nextLine();
//parsing logic
//pass parameters
}
}
else
System.out.println("Sorry, you're not allowed");
System.out.println("Done");
}
}