-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
95 lines (84 loc) · 2.89 KB
/
Copy pathMain.java
File metadata and controls
95 lines (84 loc) · 2.89 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
package Main;
import java.util.Scanner;
import service.UserService;
import Model.User;
import service.WalletService;
import util.DataStore;
import Model.transaction;
public class Main {
public static void main(String[]args){
Scanner sc = new Scanner(System.in);
UserService userService = new UserService();
WalletService walletservice = new WalletService();
while(true){
System.out.println("1. Create User ");
System.out.println("2. Add Money ");
System.out.println("3. View Balance ");
System.out.println("4. Send Money ");
System.out.println("5. view Transaction ");
System.out.println("6. Exit ");
System.out.println("Select an Option : (1,2,3,4) ");
int input = sc.nextInt();
switch (input) {
case 1:
System.out.println("Name : ");
String name = sc.next();
System.out.println("Mobile No. : ");
String Mobile = sc.next();
System.out.println("Pin : ");
int Pin = sc.nextInt();
userService.createUser(name,Mobile,Pin);
break;
case 2:
System.out.println("Enter ur Mobile No. : ");
String mobile = sc.next();
User u = userService.getUser(mobile);
if (u==null){
break;
}
else{
System.out.println("enter Amount : ");
double amount = sc.nextDouble();
u.getWallet().addMoney(amount);
System.out.println("Amount Credited Successfully");
}
break;
case 3:
System.out.println("Mobile : ");
String mobile1 = sc.next();
User u1 = userService.getUser(mobile1);
if(u1==null){
break;
}
System.out.println("Balance: " + u1.getWallet().getBalance());
break;
case 4:
System.out.println("Enter from Mobile No. : ");
String FromMobile = sc.next();
System.out.println("Enter to Mobile No. : ");
String toMobile = sc.next();
System.out.println("Amount : ");
double amount = sc.nextDouble();
System.out.print("Enter PIN: ");
int pin = sc.nextInt();
walletservice.sendMoney(FromMobile,toMobile,amount,pin);
break;
case 5:
if(DataStore.transactions.isEmpty()){
System.out.println("No Transactions Done Yet");
}
else{
for(transaction t:DataStore.transactions){
System.out.println(t);
}
}
break;
case 6:
System.out.println("Thank you for using UPI Wallet!");
System.exit(0);
default:
System.out.println("Invalid choice!");
}
}
}
}