-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
52 lines (48 loc) · 1.64 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
import javax.swing.JOptionPane;
public class Main {
static boolean logged = false;
static String welcomeMessageForLoggedUser;
static String userName;
static int accountNumber;
static double accounBalance;
static void landingPage(){
String functions = "Welcome!\n\n What do you want to do?\n 1) Login\n 2) Create client\n 3) Create account\n 0) Exit application";
String optionString = JOptionPane.showInputDialog(null, functions);
int option = Integer.parseInt(optionString);
switch(option){
case 0:
System.exit(0);
break;
case 1:
Login.login();
break;
case 2:
CreateClient.createClientFunction();
break;
case 3:
CreateAccount.createAccountFunction();
break;
default:
JOptionPane.showMessageDialog(null, "Type a valid option...");
landingPage();
}
}
static void isLogged(){
if(logged == false){
landingPage();
} else {
String welcome = String.format(welcomeMessageForLoggedUser, userName, accountNumber, accounBalance);
UserMenu.menu(welcome, accountNumber);
}
}
public static void main(String[] args) {
try {
Connect.getConnection();
isLogged();
} catch(NumberFormatException e){
logged = false;
JOptionPane.showMessageDialog(null, "You probably typed a letter where a number is expected.\nTry again...");
main(args);
}
}
}