forked from johnrogers104/PointOfSaleSystem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
95 lines (78 loc) · 3.71 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package ProcessSale;
import java.util.Scanner;
// Class to run the program
public class Main {
public static void main(String[] args) {
// Get username and password
Scanner input = new Scanner(System.in);
System.out.println("Please enter your employee ID and password");
String username = input.nextLine();
String password = input.nextLine();
LoginNoGUI login = new LoginNoGUI(username,password);
// Check validity
if (!login.isValidUser()) {
System.out.println("Please enter a valid username");
System.exit(1);
}
System.out.println("Welcome " + username + "!");
ManagingUsers userRole = new ManagingUsers(username);
String role = userRole.getRoles(username, password);
System.out.println("Role: " + role);
boolean proceed = true;
while (proceed == true) {
if (role.trim().equals("MANAGER")) { //trim() removes extra whitespace
System.out.println("Would you like to ~Add User~ ~Delete User~ ~Transaction~");
String managerAnswer = input.nextLine().toUpperCase();
if (managerAnswer.equals("ADD USER")) {
ManagingUsers addUser = new ManagingUsers(username);
System.out.println("What will be the User's new Employee_ID?");
String newID = input.nextLine();
System.out.println("What will be the User's new Employee Name?");
String newName = input.nextLine();
System.out.println("What will be the User's new Role?");
String newRole = input.nextLine();
System.out.println("What will be the User's new Password?");
String newPassword = input.nextLine();
addUser.insert(newID, newName, newRole, newPassword);
System.out.println("~Succesfully Added User~");
} else if (managerAnswer.equals("DELETE USER")) {
ManagingUsers deleteUser = new ManagingUsers(username);
System.out.println("Enter the user's password for confirmation: ");
String deleteUserPassword = input.nextLine();
deleteUser.delete(deleteUserPassword);
System.out.println("~Succesfully Deleted User~");
} else if (managerAnswer.equals("TRANSACTION")){
System.out.println("~Continue Transaction~");
proceed = false;
} else {
System.out.println("Error in Manager Answer");
}
}
}
System.out.println("\nStarting up the register...");
Register register = new Register();
register.makeNewSale();
String barcode = "";
int qty = -1;
while (!barcode.equalsIgnoreCase("q")) {
System.out.println("Please enter an item barcode, or type q to quit");
barcode = input.next();
if (!barcode.equalsIgnoreCase("q")) {
System.out.println("How many would you like?");
qty = input.nextInt();
register.enterItem(barcode, qty);
}
}
if (register.hasSale()) {
System.out.println("Please enter the credit card number or type c for cash...");
String type = input.next();
if (type.equalsIgnoreCase("c")) {
type = "cash";
}
register.makePayment(type);
register.endSale();
}
System.out.println("Thanks for coming. Bye!");
System.exit(1);
}
}