Update 05.构造程序逻辑.md

debt should be bet
pull/596/head
johnzan0743 2020-06-01 13:29:44 +10:00 committed by GitHub
parent 3ef372196c
commit e67e21e955
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 7 deletions

View File

@ -85,17 +85,17 @@
print('你的总资产为:', money) print('你的总资产为:', money)
needs_go_on = False needs_go_on = False
while True: while True:
debt = int(input('请下注: ')) bet = int(input('请下注: '))
if 0 < debt <= money: if 0 < bet <= money:
break break
first = randint(1, 6) + randint(1, 6) first = randint(1, 6) + randint(1, 6)
print('玩家摇出了%d点' % first) print('玩家摇出了%d点' % first)
if first == 7 or first == 11: if first == 7 or first == 11:
print('玩家胜!') print('玩家胜!')
money += debt money += bet
elif first == 2 or first == 3 or first == 12: elif first == 2 or first == 3 or first == 12:
print('庄家胜!') print('庄家胜!')
money -= debt money -= bet
else: else:
needs_go_on = True needs_go_on = True
while needs_go_on: while needs_go_on:
@ -104,10 +104,10 @@
print('玩家摇出了%d点' % current) print('玩家摇出了%d点' % current)
if current == 7: if current == 7:
print('庄家胜') print('庄家胜')
money -= debt money -= bet
elif current == first: elif current == first:
print('玩家胜') print('玩家胜')
money += debt money += bet
else: else:
needs_go_on = True needs_go_on = True
print('你破产了, 游戏结束!') print('你破产了, 游戏结束!')