def run_simulation(self): """The central method called in main.py.""" customer = Customer() soda_machine = SodaMachine() will_proceed = False while will_proceed: user_option = user_interface.simulation_main_menu() if user_option = "1": soda_machine.begin_transaction(customer) elif user_option = "2": customer.check_coins_in_wallet()
def run_simulation(): """The central method called in main.py.""" customer = Customer() soda_machine = SodaMachine() while True: user_option = user_interface.simulation_main_menu() if user_option == 1: soda_machine.begin_transaction(customer) elif user_option == 2: customer.check_coins_in_wallet() elif user_option == 3: customer.check_backpack() elif user_option == 4: quit()
def run_simulation(self): """The central method called in main.py.""" customer = Customer() soda_machine = SodaMachine() will_proceed = False if not will_proceed: user_option = user_interface.simulation_main_menu() if user_option == 1: soda_machine.begin_transaction(customer) elif user_option == 2: customer.check_coins_in_wallet() elif user_option == 3: customer.check_backpack() else: will_proceed = False return will_proceed
class Simulation: def __init__(self): self.customer = Customer() self.soda_machine = SodaMachine() pass def run_simulation(self): """The central method called in main.py.""" will_proceed = True while will_proceed: user_option = user_interface.simulation_main_menu() if user_option == 1: self.soda_machine.begin_transaction(self.customer) elif user_option == 2: self.customer.check_coins_in_wallet() elif user_option == 3: self.customer.check_backpack() else: will_proceed = False
def run_simulation(self): """The central method called in main.py.""" customer = Customer() soda_machine = SodaMachine() soda_machine.fill_inventory() soda_machine.fill_register() will_proceed = True while will_proceed: user_option = user_interface.simulation_main_menu() if user_option == 0: soda_machine.begin_transaction(customer) elif user_option == 1: customer.check_coins_in_wallet() elif user_option == 2: customer.check_backpack() elif user_option == 3: will_proceed = False
def soda_machine(): return SodaMachine.start([("Coke", 10, 10)], "visa_server", "username", "password")
def test_create_soda_machine_with_invalid_params(drink_name, amount, price): with pytest.raises(Exception): SodaMachine.start([(drink_name, amount, price)])
def test_create_soda_machine(): machine = SodaMachine.start([("Coke", 10, 10)], "visa_server", "username", "password") assert "Coke" in machine.drinks, "Coke is missing in machine" assert machine.drinks["Coke"].price == 10, "Wrong price was set to Coke" assert machine.drinks["Coke"].amount == 10, "Wrong amount was set to Coke"
def __init__(self): self.customer = Customer() self.soda_machine = SodaMachine() pass
from soda_machine import SodaMachine if __name__ == "__main__": mm = SodaMachine() mm.load_machine()