def start_menu(): # Start menu (create account, log in, exit) start_done = False while not start_done: user_input = view.start_menu() if user_input == "1": username, password = view.create_account_menu() status = model.create_account(username, password) print(status) if "Success" in status: start_done = True exit = view.wait("main menu") return username else: exit = view.wait("previous menu") elif user_input == "2": username, password = view.login_menu() status = model.login(username, password) print(status) if "Success" in status: start_done = True exit = view.wait("main menu") return username else: exit = view.wait("previous menu") elif user_input == "3": status = view.exit_message() start_done = True print(status) return "exit"
def run(): while True: choice = view.main_menu() if choice == "3": #Exit return elif choice == "1": #Create Account view.create_account() fname = view.first_name() lname = view.last_name() pin = view.choose_pin() initial = float(view.deposit_initial()) #Create new account then display view.new_account(model.create_account(fname, lname, pin, initial)) elif choice == "2": #log in account_num, pin = view.login() #Check if login info is correct if model.login(account_num, pin) == False: view.bad_login() else: #Login Menu - Check Balance, Withdraw, Deposit, Open Savings Account info = model.login(account_num, pin) view.welcome(account_num, info) while True: choice = view.login_menu() if choice == "1": view.check_balance(info) elif choice == "2": login_withdrawal(account_num) #see line 58 elif choice == "3": num = view.deposit() new_balance = model.deposit(num, account_num) view.deposit_new_balance(num, new_balance) elif choice == "4": from_account, to_account, amount = view.transfer() #Add " account" at the end of the string so it matches the key in the dictionary from_account = from_account + " account" to_account = to_account + " account" #convert amount value from string to float amount = float(amount) info = model.transfer(from_account, to_account, amount, account_num) view.transfer_new_balance(info, from_account, to_account) elif choice == "5": yesorno, deposit = view.create_savings() model.open_savings(yesorno, float(deposit), account_num) view.savings_opened(float(deposit)) elif choice == "6": view.signout() return else: view.bad_input()
def game_loop(): while True: user_input = view.main_menu().lower() buy_inputs = ["b", "buy"] sell_inputs = ["s", "sell"] lookup_inputs = ["l", "lookup"] quote_inputs = ["q", "quote"] exit_inputs = ["e", "exit"] acceptable_inputs = buy_inputs \ +sell_inputs \ +lookup_inputs \ +quote_inputs \ +exit_inputs if user_input in acceptable_inputs: if user_input in buy_inputs: # FIXME # State of the Program: ## User wants to buy stock ### company referred to by TICKER SYMBOL #### global unique identifiers ## What we should try to do next (ie sudo code) ## --trader_name ## --ticker_symbol ## --trade_volume ## --limit_price --> coming from `view` ## --time_stamp --> defined in `model` ## "we're building out the order ticket" (username, password) = view.login_menu() (ticker_symbol, trade_volume) = view.buy_menu() ####################################### with model.User(username) as u: if u.login(password): # excute the buy order, # if there's enough money in acct confirmation_message = u.buy(ticker_symbol, trade_volume) print(confirmation_message) pass pass elif user_input in sell_inputs: # FIXME pass
def login_loop(): account_num, pin_login = view.login_menu() fname, lname = model.login(account_num, pin_login) account_loop(fname, lname, account_num)
def create_user(): username, pwd = view.login_menu() model.create_user(username, pwd)
def login(): username, pwd = view.login_menu() user = model.login(username, pwd) return user != None, user