-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChoiceMenu.java
More file actions
175 lines (137 loc) · 3.69 KB
/
ChoiceMenu.java
File metadata and controls
175 lines (137 loc) · 3.69 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
package ATM;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;
public class ChoiceMenu extends Account {
Scanner menuInput=new Scanner(System.in);
DecimalFormat money=new DecimalFormat("'$'###,##0.00");
HashMap<Integer, Integer> data=new HashMap<Integer, Integer>();
//Validate login information customer number and pin number
public void getLogin() throws IOException
{
int x=1;
do
{
try
{
/*
* Accounts in a HashMap form, key = customer number, value = pin
* number
*/
data.put(123123123, 12345);
data.put(123412345, 1236);
System.out.println("Welcome to the ATM Project!");
System.out.println("Enter your Customer Number: ");
setCustomerNumber(menuInput.nextInt());
System.out.println("Enter your pin: ");
setPinNumber(menuInput.nextInt());
}
catch(Exception e)
{
System.out.println("\n" + "Inavlid character(s). Only numbers." + "\n");
x=2;
}
//loop for checking customerNumber and pinNumber
for(Entry<Integer,Integer> entry:data.entrySet())
{
if(entry.getKey()==getCustomerNumber() && entry.getValue()==getPinNumber())
{
getAccountType();
}
}
System.out.println("\n" + "Wrong Customer Number or Pin Number." + "\n");
}while(x==1);
}
//Account type menu with selection
public void getAccountType()
{
System.out.println("Select the Account you want to access: ");
System.out.println("Type 1- Checking Account");
System.out.println("Type 2- Saving Account");
System.out.println("Type 3- Exit");
System.out.println("Choice: ");
selection=menuInput.nextInt();
switch(selection)
{
case 1:
getChecking();
break;
case 2:
getSaving();
break;
case 3:
System.out.println("Thank You for using this ATM: ");
break;
default:
System.out.println("\n" + "Inavlid Choice. " + "\n");
getAccountType();
}
}
//Display Checking Account Menu with Selections
public void getChecking()
{
System.out.println("Checking Account: ");
System.out.println("Type 1- View Balance");
System.out.println("Type 2- Withdraw Money");
System.out.println("Type 3- Deposit Money");
System.out.println("Type 4- Exit");
System.out.println("Choice: ");
selection=menuInput.nextInt();
switch(selection)
{
case 1:
System.out.println("Checking Account Balance: " + money.format(getCheckingBalance()) + "\n");
getAccountType();
break;
case 2:
getCheckingWithdrawlInput();
getAccountType();
break;
case 3:
getCheckingDepositInput();
getAccountType();
break;
case 4:
System.out.println("Thank You for using this ATM. ");
break;
default:
System.out.println("\n" + "Invalid choice." + "\n");
getChecking();
}
}
//Display saving account menu with selection
public void getSaving()
{
System.out.println("Saving Account: ");
System.out.println("Type 1- View Balance");
System.out.println("Type 2- Withdraw Money");
System.out.println("Type 3- Deposit Money");
System.out.println("Type 4- Exit");
System.out.println("Choice: ");
selection=menuInput.nextInt();
switch(selection)
{
case 1:
System.out.println("Saving Account Balance: " + money.format(getSavingBalance()) + "\n");
getAccountType();
break;
case 2:
getSavingWithdrawlInput();
getAccountType();
break;
case 3:
getSavingDepositInput();
getAccountType();
break;
case 4:
System.out.println("Thank You for using this ATM. ");
break;
default:
System.out.println("\n" + "Invalid choice." + "\n");
getSaving();
}
}
int selection;
}