码迷,mamicode.com
首页 > 其他好文 > 详细

第12章第一题

时间:2019-12-16 15:05:06      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:else   amount   self   with   ini   ant   退出   import   pos   

#_author:Ltx
#date:2019/12/16
import time
import random
class account:
‘‘‘
1.存款功能
2.取款功能
3.打印交易详情
3.1--每次交易的时间
3.2--存款或者取款的金额
3.3每次交易后的金额
‘‘‘

def __init__(self,balance=10000):
self.balance=balance
@property
def show(self):
flag = True
while flag:
msg = ‘‘‘
1. 存款
2. 取款
3. 退出
‘‘‘
print(‘请选择你要使用的功能:‘,msg)
choose=int(input(‘请选择:‘))
if choose==1:
self.deposit
elif choose==2:
self.withdrawal
elif choose==3:
flag=False
else:
print(‘您输入有误‘)
@property
def deposit(self):
inp=input(‘请输入你要存款的金额:‘)# Please enter the amount you want to deposit
inp=int(inp)
print(‘您存入的金额为‘,inp,time.ctime())
self.balance+=inp
print(‘您的余额是‘,self.balance)
@property
def withdrawal(self):
re=int(input(‘请输入你要取的金额:‘))
if re<self.balance:
self.balance-=re
print(‘取款成功,您的余额为:‘,self.balance,time.ctime())
else:
print(‘余额不足,您的余额为:‘,self.balance,‘请重新输入取款金额‘)
flag=False
a1=account()
a1.show

第12章第一题

标签:else   amount   self   with   ini   ant   退出   import   pos   

原文地址:https://www.cnblogs.com/startl/p/12048932.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!