The code works, but the bug is that it doesn't always pick the right bank account.
Code:
mob/Banker
icon = 'Banker.dmi'
mob
var
SavingsAccount = 0 //This is the players Savings Account
ChequingsAccount = 0 // And Chequings Account
Interest = 0 //This hasn't been applied yet
LineOfCredit = 500 //This is the Line of Credit stored as a player variable
AccountChoice //This is the Account Choice from SelectAccount()
mob/Banker
verb
UseBank()
set src in view()
var/l = (input("Welcome, What kind of banking would you like to do today?") in list("Withdraw Money", "Deposit Money", "Check Balance", "Exit"))
if (l == "Withdraw Money")
WithdrawMoney()
else if (l == "Deposit Money") //I didn't include the Deposit Money in the problem help because it's the same problem
DepositMoney()
else if (l == "Check Balance")
CheckBalance()
else if (l == "Exit")
return
proc
SelectAccount()
set src in view()
switch (alert("What account would you like to use today?", "Account Selection", "Chequings Account", "Savings Account", "Line of Credit"))
if ("Chequings Account")
usr.AccountChoice = usr.ChequingsAccount
if ("Savings Account")
usr.AccountChoice = usr.SavingsAccount
else if ("Line of Credit")
usr.AccountChoice = usr.LineOfCredit
proc
//Use_Bank()
WithdrawMoney()
set src in view()
SelectAccount()
var/s = (input("How Much Would You Like to Withdraw Today") as num)
if (usr.AccountChoice == usr.ChequingsAccount)
if (usr.ChequingsAccount >= s)
usr.ChequingsAccount -= s
usr.Money += s
usr << "You withdraw $[s] from your Chequings Account leaving you with a balance of $[usr.ChequingsAccount]"
usr.AccountChoice = ""
else usr << "Sorry, You Don't have enough in your Chequings Account... Your Current Balance is $[usr.ChequingsAccount]"
else if (usr.AccountChoice == usr.SavingsAccount)
if (usr.SavingsAccount >= s)
usr.SavingsAccount -= s
usr.Money += s
usr << "You withdraw $[s] from your Savings Account leaving you with a balance of $[usr.SavingsAccount]"
usr.AccountChoice = ""
else usr << "Sorry, You Don't have enough in your Savings Account... Your Current Balance is $[usr.SavingsAccount]"
else if (usr.AccountChoice == usr.LineOfCredit)
if (usr.LineOfCredit >= s)
usr.LineOfCredit -= s
usr.Money += s
usr << "You withdraw $[s] from your Line of Credit... You currently have a limit of $[usr.LineOfCredit] remaining in your balance"
usr.AccountChoice = ""
else usr << "Sorry... You don't have enough on your Line of Credit to make that transaction"
Problem description: I think the problem is that the AccountChoice variable is Equal to both Chequings Account and Savings Account or Line of Credit... The problem with this code is that it sometimes registers as Savings Account for Line of Credit and registers and Chequings Account for Savings, etc.... Besides that everything works.
What you need is
e.t.c.