示例#1
0
def main():
    food, clothing, entertainment = 0, 0, 0
    budget = Budget(food, clothing, entertainment)
    performOperation = 'Y'
    while (performOperation == 'Y') or (performOperation == 'y'):
        print("What would you like to do?\n")
        print("1. Make deposit\n")
        print("2. Make withdrawals\n")
        print("3. Check balance\n")
        print("4. Transfer inter-budgets\n")
        option = input("Select from the above\n")
        if option == '1':
            amount = int(input("How much would you like to deposit? \n"))
            budget.deposit(amount)
        elif option == '2':
            amount = int(input("How much would you like to withdraw? \n"))
            budget.withdraw(amount)
        elif option == '3':
            budget.balance()
        elif option == '4':
            budget.transferBalance()
        else:
            print("You have entered an invalid input.")
        performOperation = input(
            "Wanna perform another operation? Enter Y for YES or any other character for NO\n"
        )
示例#2
0
from budget import Budget

food = Budget()
clothing = Budget()
entertainment = Budget()

food.deposit(500)
clothing.deposit(600)
entertainment.deposit(1000)

food.withdraw(300)
clothing.withdraw(800)
entertainment.withdraw(800)

print("Balance after withdrawing")
print(food.balance)
print(clothing.balance)
print(entertainment.balance)

print("Balance after transferring")
food.acceptTransfer(clothing.makeTransfer(300))
entertainment.acceptTransfer(food.makeTransfer(200))

print(food.balance)
print(clothing.balance)
print(entertainment.balance)
示例#3
0
from budget import Budget
food_budget = Budget('food', 200)
clothing_budget = Budget('clothes', 100)

food_budget.deposit(50)
print(food_budget.balance)

food_budget.deposit('foo')