-
Notifications
You must be signed in to change notification settings - Fork 0
/
Homepage.java
208 lines (184 loc) · 4.98 KB
/
Homepage.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
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
package Banking_System;
import java.util.Scanner;
/*
This is Demo System Of Banking System. Written In Java
By :- Bernabas Tekklign;
Gitub User Name------ "@Barnaan2"
Email Address ------ "BarnaanTekalign@gmail.com"
" CopyRight--- feel free to use it for any purpose"
*/
// Interface for the user
class Home_page{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
login(input);
}
//welcome
public static int welcome (Scanner input){
Admin obj = new Admin();
obj = Admin_method.getObject(20001);
Banker obji = new Banker();
obji= Banker_method.getObject(30001);
System.out.println(" Welcome to Barnaan2 Banking System: ");
System.out.println(" ");
System.out.println(" Exit: [0]");
System.out.println(" Login As Admin: [1] ");
System.out.println(" Login As Employee: [2]");
System.out.print(" Your Choice: ");
int login_choice = input.nextInt();
System.out.println("");
System.out.println("");
System.out.println(" To start With the System -- Admin Id is = 20001 and Password is [" + obj.get_password()+"]");
System.out.println(" To start With the System as Employee -- Employee Id is = 30001 and Password is [" + obji.get_password()+"]");
System.out.println(" ");
System.out.print(" Your Choice: ");
return login_choice;
}
public static void login(Scanner insert){
try{
int num = welcome(insert);
switch(num){
case 0:
System.exit(0);
System.out.println(" You Exited ");
break;
case 1:
System.out.println("*************");
adminValidate(insert);
break;
case 2:
System.out.println("************");
employeeValidate(insert);
break;
default:
System.out.println("please select [0]---[3]");
login(insert);
break;
}}
catch(Exception e){
System.out.println("choose only number not a Spelling or onther chars");
Scanner again = new Scanner(System.in);
login(again);
}
}
static int trial=0;
static void adminValidate(Scanner insert)
{// type 1 for Admin 2 for banker for customers
int type = 1;
System.out.println("Enter Your Administerator Id Number: ");
System.out.print(" Your ID Number: ");
int Id = insert.nextInt();
if(Authenthicator(Id,type)){
adminWelcome(insert,Id);
}
else{
trial ++;
if(trial >= 3)
{
System.out.println("You Have Tried Three Times! Access Denied. ");
System.exit(0);}
System.out.println("Your ID number was incorrect please try again");
System.out.println("Alert [--Id Number Format--] is 2000 ");
}
adminValidate(insert);
}
static void employeeValidate(Scanner insert)
{int type = 2;
System.out.println("Enter Your Employee Id Number");
System.out.print(" Your ID Number: ");
int Id = insert.nextInt();
if(Authenthicator(Id,type)){
employeeWelcome(insert,Id);
}
else{
if(trial >= 3)
{
System.out.println("You Have Tried Three Times! Access Denied. ");
System.exit(0);
}
System.out.println("Your Id Number Is Incorret");
System.out.println("Alert [--Id Number Format--] is 3000");
employeeValidate(insert);
}
}
static int Trial = 0;
static void adminWelcome(Scanner input,int Id){
System.out.println("welcome to Admin page");
Admin_method admin = new Admin_method();
if(admin.checkPassword(Id)){
admin.operations(input);
}
else {
Trial ++;
if(Trial >= 3)
{
System.out.println("You password Was Not Correct! you have tried ["+Trial+"]times! Access Denied");
Trial =0;
login(input);
}
System.out.println("You password Was Not Correct! you have tried ["+Trial+"] times!try gain");
adminWelcome(input, Id);
}
}
static void employeeWelcome(Scanner input , int id){
System.out.println("welcome to Employee");
Banker_method employee= new Banker_method();
if(employee.checkPassword(id)) {
employee.operations(input);
}
else {
Trial ++;
if(Trial >= 3)
{
System.out.println("You password Was Not Correct! you have tried ["+Trial+"]times! Access Denied");
Trial =0;
login(input);
}
System.out.println("You password Was Not Correct! you have tried ["+Trial+"]times! try gain");
employeeValidate(input);
}
}
public static boolean Authenthicator(int Id,int type){
boolean checked = false;
String file = Methods.getFileName(Id);
switch(type){
case 1:
// check id range for administrators
if(file!= null)
{ int idrange = 20000;
if((Id >=idrange)&&(Id < 30000))
{ checked = true;}
else {
checked = false;
}
}
break;
case 2:
// this is id range for the bankers
if(file!= null)
{ int idrange = 30000;
if((Id >=idrange)&&(Id < 50000))
{ checked = true;}
else {
checked = false;
}
}
break;
case 3:
// this is id range
if(file!= null)
{ int idrange = 10000;
if((Id >=idrange)&&(Id < 20000))
{ checked = true;}
else {
checked = false;
}
}
break;
default:
System.out.println("access is denied! ");
break;
}
return checked;
}
}