Ejemplo n.º 1
0
    def test_has_enough_money_handles_insufficient_funds(self):
        """
        test has_enough_money handles insufficient funds functionality
        """
        # Params
        f_money_collected = 2.00
        f_chocolate_price = 2.25

        # Returns
        return_1 = 'Insufficient funds...  Dispensing coins inserted.\n'

        # Calls
        string_1 = has_enough_money(f_money_collected, f_chocolate_price)

        # Asserts
        self.assertEqual(string_1, return_1)
Ejemplo n.º 2
0
    def test_has_enough_money(self):
        """
        test has_enough_money functionality
        """
        # Params
        f_money_collected = 2.50
        f_chocolate_price = 2.25

        # Returns
        return_1 = 'Change: $0.25\n'

        # Calls
        string_1 = has_enough_money(f_money_collected, f_chocolate_price)

        # Asserts
        self.assertEqual(string_1, return_1)
Ejemplo n.º 3
0
    elif choice == 'stats':
        stats_ = stats(raw_materials)
        print(stats_)
    elif valid_choice:
        selection = CUPCAKE_CHOICES[choice]
        has_enough_raw_materials = has_raw_materials(selection['ingredients'],
                                                     raw_materials)
        if not isinstance(has_enough_raw_materials, bool):
            print(has_enough_raw_materials)
            machine_active = False
        if isinstance(has_enough_raw_materials, bool):
            quarters = input('Quarters: ')
            dimes = input('Dimes: ')
            nickels = input('Nickels: ')
            money = collect_money(100.00, quarters, dimes, nickels)
            if not isinstance(money, float):
                print(money)
            else:
                change = has_enough_money(money, selection['price'])
                if change == 'Insufficient funds...  Dispensing coins inserted.\n':
                    print(change)
                else:
                    cupcake = bake_cupcake(choice, selection['ingredients'],
                                           raw_materials)
                    print(cupcake)
                    print(change)
        else:
            machine_active = False

print('We are going down for maintenance...')
Ejemplo n.º 4
0
        stats_ = stats(raw_materials, total_money_collected)
        print(stats_)
    elif valid_choice:
        selection = CHOCOLATE_CHOICES[choice]
        has_enough_raw_materials = has_raw_materials(selection['ingredients'],
                                                     raw_materials)
        if not isinstance(has_enough_raw_materials, bool):
            print(has_enough_raw_materials)
            machine_active = False
        if isinstance(has_enough_raw_materials, bool):
            quarters = input('Quarters: ')
            dimes = input('Dimes: ')
            nickels = input('Nickels: ')
            money = collect_money(100.00, quarters, dimes, nickels)
            if not isinstance(money, float):
                print(money)
            else:
                change = has_enough_money(money, selection['price'],
                                          total_money_collected)
                if change == 'Insufficient funds...  Dispensing coins inserted.\n':
                    print(change)
                else:
                    chocolate_bar = bake_chocolate_bar(
                        choice, selection['ingredients'], raw_materials)
                    print(chocolate_bar)
                    print(change)
        else:
            machine_active = False

print('We are going down for maintenance...')
Ejemplo n.º 5
0
                elif spend_point in SPEND_POINT_NO:
                    machine_active = False
                else:
                    print('That is not a valid selection...\n')
            else:
                machine_active = False
        if isinstance(has_enough_raw_materials, bool):
            print('A {0} cupcake costs {1:.2f}'.format(choice,
                                                       selection['price']))
            quarters = input('Quarters: ')
            dimes = input('Dimes: ')
            nickels = input('Nickels: ')
            money = collect_money(100.00, quarters, dimes, nickels)
            if not isinstance(money, float):
                print(money)
            else:
                change, secret_points, total_money_collected = has_enough_money(
                    money, selection['price'], secret_points,
                    total_money_collected)
                if change == 'Insufficient funds...  Dispensing coins inserted.\n':
                    print(change)
                else:
                    cupcake = bake_cupcake(choice, selection['ingredients'],
                                           raw_materials)
                    print(cupcake)
                    print(change)
        else:
            machine_active = False

print('We are going down for maintenance...')