-
Notifications
You must be signed in to change notification settings - Fork 0
/
hello.kt
120 lines (108 loc) · 2.6 KB
/
hello.kt
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
import java.util.*;
val Withdrawl =1
val Deposit= 2
val Ministatement=3
val DisplayAmount=4
val Exit=5
var userChoice: Int= Withdrawl
var homeChoice: Int = 1;
fun main(args: Array<String>)
{
println("***** Welcome to the Bank *****")
var bank: Bank = Bank()
do{
doHomeScreenAction(bank)
//doBankActionFromUserInput(bank)
}while(homeChoice!=3)
println()
println("***** Thank you!!! *****")
}
fun homeScreen()
{
println()
println("Choose any one")
println("1: Register")
println("2: Login")
println("3: Exit")
}
fun greetUserWithChoice()
{
println()
println("Choose from the below options:")
println("1: Withdrawl")
println("2: Deposite")
println("3: Ministatement")
println("4: Display Amount")
println("5: Exit")
}
fun getDepositeAmountFromUser():Double
{
print("Add amount to Deposit :- ")
val depositeAmount= readLine()!!.toDouble()
return depositeAmount
}
fun getWithdrawlAmountFromUser():Double
{
print("Enter amount to Withdraw :- ")
val WithdrawlAmount= readLine()!!.toDouble()
return WithdrawlAmount
}
fun doBankActionFromUserInput(bank: Bank, accNum: String)
{
do
{
greetUserWithChoice()
userChoice=readLine()!!.toInt()
if(userChoice==Deposit)
{
var depositAmount= getDepositeAmountFromUser()
bank.deposit(depositAmount,accNum)
println("Date: ${bank.getCurrentDate(System.currentTimeMillis())}")
}
else if(userChoice==Withdrawl)
{
var WithdrawlAmount= getWithdrawlAmountFromUser()
bank.withdrawl(WithdrawlAmount,accNum)
}
else if(userChoice==Ministatement)
{
bank.showMinistatement(accNum)
}
else if(userChoice==DisplayAmount)
{
bank.showBalance(accNum)
}
}while(userChoice!=Exit)
}
fun doHomeScreenAction(bank: Bank)
{
homeScreen()
homeChoice=readLine()!!.toInt()
if(homeChoice==1)
{
print("Enter your Name :-")
var name= readLine()!!.toString()
print("Enter your Account Number :-")
var accNum = readLine()!!.toString()
print("Enter your Password :-")
var password= readLine()!!.toString()
print("Enter your Mobile Number :-")
var mob= readLine()!!.toString()
var amount: Double= 0.0
bank.registration(name,accNum,password,mob,amount)
}
else if(homeChoice==2)
{
print("Enter your Account Number :-")
var accNum = readLine()!!.toString()
print("Enter your Password :-")
var password= readLine()!!.toString()
if(bank.checkLogin(accNum,password))
{
doBankActionFromUserInput(bank,accNum)
}
else{
println("Invalid User!!!")
}
}
}