-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBookkeepingApp.java
More file actions
101 lines (89 loc) · 3.37 KB
/
BookkeepingApp.java
File metadata and controls
101 lines (89 loc) · 3.37 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
import java.util.Scanner;
public class BookkeepingApp {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Bank bank = new Bank();
while (true) {
System.out.println("Login as:\n1. Admin\n2. Customer\n3. Exit");
int userType = scanner.nextInt();
if (userType == 1) {
Admin admin = loginAdmin(scanner, bank);
adminMenu(scanner, admin);
} else if (userType == 2) {
Customer customer = loginCustomer(scanner, bank);
customerMenu(scanner, customer);
} else if (userType == 3) {
System.out.println("Exiting the application. Goodbye!");
break;
} else {
System.out.println("Invalid choice. Please enter a valid option.");
}
}
}
private static Admin loginAdmin(Scanner scanner, Bank bank) {
System.out.println("Enter admin username:");
String username = scanner.next();
System.out.println("Enter admin password:");
String password = scanner.next();
return new Admin(username, password, bank);
}
private static Customer loginCustomer(Scanner scanner, Bank bank) {
System.out.println("Enter customer username:");
String username = scanner.next();
System.out.println("Enter customer password:");
String password = scanner.next();
return new Customer(username, password, bank);
}
private static void adminMenu(Scanner scanner, Admin admin) {
while (true) {
System.out.println("\nAdmin Menu:");
System.out.println("1. Add Customer");
System.out.println("2. View All Customers");
System.out.println("3. Exit");
int choice = scanner.nextInt();
switch (choice) {
case 1:
admin.addCustomer();
break;
case 2:
admin.viewAllCustomers();
break;
case 3:
System.out.println("Exiting admin menu.");
return;
default:
System.out.println("Invalid choice. Please enter a valid option.");
}
}
}
private static void customerMenu(Scanner scanner, Customer customer) {
while (true) {
System.out.println("\nCustomer Menu:");
System.out.println("1. Deposit");
System.out.println("2. Withdraw");
System.out.println("3. Transfer");
System.out.println("4. View Transactions");
System.out.println("5. Exit");
int choice = scanner.nextInt();
switch (choice) {
case 1:
customer.deposit();
break;
case 2:
customer.withdraw();
break;
case 3:
customer.transfer();
break;
case 4:
customer.viewTransactions();
break;
case 5:
System.out.println("Exiting customer menu.");
return;
default:
System.out.println("Invalid choice. Please enter a valid option.");
}
}
}
}