示例#1
0
文件: client.py 项目: hagifoo/learn
from vending_machine import VendingMachine
from drink import Drink

if __name__ == '__main__':
    print('# 200円を入れて 0: COKE を購入')

    money = 200
    drink_type = 0
    vending_machine = VendingMachine()
    my_drink = vending_machine.buy(money, drink_type)
    change = vending_machine.refund()

    print('Drink: {}'.format(my_drink))
    print('Change: {}'.format(change))
    print('->100円か500円しか受け付けないのでそのまま返ってくる')

    print('# 500円を入れて 1: DIET_COKE を購入')

    money = 500
    drink_type = 1
    vending_machine = VendingMachine()
    my_drink = vending_machine.buy(money, drink_type)
    change = vending_machine.refund()

    print('Drink: {}'.format(my_drink.get_kind()))
    print('Change: {}'.format(change))
    print('->DIET_COKEが出て400円返ってくる')
示例#2
0
from drink import Drink
from coin_holder import CoinHolder
from vending_machine import VendingMachine
from coin import Coin

if __name__ == '__main__':
    my_vending_machine = VendingMachine()
    coins = CoinHolder(yen_500=0, yen_100=12, yen_10=10)

    my_drink = my_vending_machine.buy(coins, Drink.COKE)
    refund = my_vending_machine.refund()

    print("my_drink:", my_drink)
    print("refund: ", refund.__dict__)
    print("vending_coins: ",
          my_vending_machine.vending_coin_holder.coin_holder.__dict__)
    print("vending_drinks: ", my_vending_machine.drink_holder.__dict__)

    for coins in Coin:
        print()
示例#3
0
from vending_machine import VendingMachine

if __name__ == '__main__':
    print('# 200円を入れて 0: COKE を購入')

    money = 200
    drink_type = 0
    vending_machine = VendingMachine()
    my_drink = vending_machine.buy(money, drink_type)
    change = vending_machine.refund()

    print('Drink: {}'.format(my_drink))
    print('Change: {}'.format(change))
    print('->100円か500円しか受け付けないのでそのまま返ってくる')

    print('# 500円を入れて 1: DIET_COKE を購入')

    money = 500
    drink_type = 1
    vending_machine = VendingMachine()
    my_drink = vending_machine.buy(money, drink_type)
    change = vending_machine.refund()

    print('Drink: {}'.format(my_drink.get_kind()))
    print('Change: {}'.format(change))
    print('->DIET_COKEが出て400円返ってくる')
示例#4
0
from vending_machine import VendingMachine
from drink import Drink

if __name__ == '__main__':
    money = 200
    drinkType = 0
    vendingMachine = VendingMachine()
    myDrink = vendingMachine.buy(money, drinkType)
    change = vendingMachine.refund()
    print(myDrink)
    print(change)