|
|
@ -20,6 +20,8 @@ class ATM(object):
|
|
|
|
|
|
|
|
|
|
|
|
def newAccount(self):
|
|
|
|
def newAccount(self):
|
|
|
|
# 输入身份证号和手机号
|
|
|
|
# 输入身份证号和手机号
|
|
|
|
|
|
|
|
if not check.isSure("是否开户\n"):
|
|
|
|
|
|
|
|
return
|
|
|
|
pnum = check.phoneNumInput()
|
|
|
|
pnum = check.phoneNumInput()
|
|
|
|
iden = check.identifyInput()
|
|
|
|
iden = check.identifyInput()
|
|
|
|
print("正在执行开户程序,请稍候...")
|
|
|
|
print("正在执行开户程序,请稍候...")
|
|
|
@ -35,7 +37,7 @@ class ATM(object):
|
|
|
|
# 初始化卡号密码,卡里的钱,卡的锁定状态
|
|
|
|
# 初始化卡号密码,卡里的钱,卡的锁定状态
|
|
|
|
card = Card(cardN, '000000', 0, iden, pnum, 'False')
|
|
|
|
card = Card(cardN, '000000', 0, iden, pnum, 'False')
|
|
|
|
self.appendCard.append(card)
|
|
|
|
self.appendCard.append(card)
|
|
|
|
print("开户成功,您的卡号为%s,密码为%s,卡余额为%d。" % (cardN, '888888', 0))
|
|
|
|
print("开户成功,您的卡号为%s,密码为%s,卡余额为%d。" % (cardN, '000000', 0))
|
|
|
|
print("请牢记密码,不要把密码泄露给他人。")
|
|
|
|
print("请牢记密码,不要把密码泄露给他人。")
|
|
|
|
# 更新卡号列表
|
|
|
|
# 更新卡号列表
|
|
|
|
self.cards = self.readCard.read()
|
|
|
|
self.cards = self.readCard.read()
|
|
|
@ -43,6 +45,8 @@ class ATM(object):
|
|
|
|
|
|
|
|
|
|
|
|
# 查询
|
|
|
|
# 查询
|
|
|
|
def checkMoney(self):
|
|
|
|
def checkMoney(self):
|
|
|
|
|
|
|
|
if not check.isSure("是否查询\n"):
|
|
|
|
|
|
|
|
return
|
|
|
|
card = check.isCardExist(self.cards)
|
|
|
|
card = check.isCardExist(self.cards)
|
|
|
|
if check.isCardLock(self.cards, card.cardN):
|
|
|
|
if check.isCardLock(self.cards, card.cardN):
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -52,6 +56,8 @@ class ATM(object):
|
|
|
|
|
|
|
|
|
|
|
|
# 存储
|
|
|
|
# 存储
|
|
|
|
def saveMoney(self):
|
|
|
|
def saveMoney(self):
|
|
|
|
|
|
|
|
if not check.isSure("是否存储\n"):
|
|
|
|
|
|
|
|
return
|
|
|
|
card = check.isCardExist(self.cards)
|
|
|
|
card = check.isCardExist(self.cards)
|
|
|
|
if check.isCardLock(self.cards, card.cardN):
|
|
|
|
if check.isCardLock(self.cards, card.cardN):
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -66,6 +72,8 @@ class ATM(object):
|
|
|
|
|
|
|
|
|
|
|
|
# 取款
|
|
|
|
# 取款
|
|
|
|
def getMoney(self):
|
|
|
|
def getMoney(self):
|
|
|
|
|
|
|
|
if not check.isSure("是否取款\n"):
|
|
|
|
|
|
|
|
return
|
|
|
|
card = check.isCardExist(self.cards)
|
|
|
|
card = check.isCardExist(self.cards)
|
|
|
|
if check.isCardLock(self.cards, card.cardN):
|
|
|
|
if check.isCardLock(self.cards, card.cardN):
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -80,10 +88,11 @@ class ATM(object):
|
|
|
|
|
|
|
|
|
|
|
|
print("取款成功!你卡上的余额为%d元!" % self.cards[index].cardMoney)
|
|
|
|
print("取款成功!你卡上的余额为%d元!" % self.cards[index].cardMoney)
|
|
|
|
time.sleep(1)
|
|
|
|
time.sleep(1)
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 转账
|
|
|
|
# 转账
|
|
|
|
def inMoney(self):
|
|
|
|
def inMoney(self):
|
|
|
|
|
|
|
|
if not check.isSure("是否转帐\n"):
|
|
|
|
|
|
|
|
return
|
|
|
|
card = check.isCardExist(self.cards)
|
|
|
|
card = check.isCardExist(self.cards)
|
|
|
|
if check.isCardLock(self.cards, card.cardN):
|
|
|
|
if check.isCardLock(self.cards, card.cardN):
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -117,10 +126,11 @@ class ATM(object):
|
|
|
|
self.writeCard()
|
|
|
|
self.writeCard()
|
|
|
|
print("转账成功!你卡上的余额为%d元!" % self.cards[index].cardMoney)
|
|
|
|
print("转账成功!你卡上的余额为%d元!" % self.cards[index].cardMoney)
|
|
|
|
time.sleep(1)
|
|
|
|
time.sleep(1)
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 销户
|
|
|
|
# 销户
|
|
|
|
def DAccount(self):
|
|
|
|
def DAccount(self):
|
|
|
|
|
|
|
|
if not check.isSure("是否销户\n"):
|
|
|
|
|
|
|
|
return
|
|
|
|
card = check.isCardInfoSure(self.cards)
|
|
|
|
card = check.isCardInfoSure(self.cards)
|
|
|
|
if card:
|
|
|
|
if card:
|
|
|
|
self.cards.remove(card)
|
|
|
|
self.cards.remove(card)
|
|
|
@ -128,10 +138,10 @@ class ATM(object):
|
|
|
|
|
|
|
|
|
|
|
|
print("销户成功!")
|
|
|
|
print("销户成功!")
|
|
|
|
time.sleep(1)
|
|
|
|
time.sleep(1)
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 挂失
|
|
|
|
# 挂失
|
|
|
|
def hangOutAccount(self):
|
|
|
|
def hangOutAccount(self):
|
|
|
|
|
|
|
|
if not check.isSure("是否挂失\n"):
|
|
|
|
|
|
|
|
return
|
|
|
|
card = check.isCardInfoSure(self.cards)
|
|
|
|
card = check.isCardInfoSure(self.cards)
|
|
|
|
if check.isCardLock(self.cards, card.cardN):
|
|
|
|
if check.isCardLock(self.cards, card.cardN):
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -142,10 +152,11 @@ class ATM(object):
|
|
|
|
|
|
|
|
|
|
|
|
print("挂失成功!")
|
|
|
|
print("挂失成功!")
|
|
|
|
time.sleep(1)
|
|
|
|
time.sleep(1)
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 解锁
|
|
|
|
# 解锁
|
|
|
|
def unlockAccount(self):
|
|
|
|
def unlockAccount(self):
|
|
|
|
|
|
|
|
if not check.isSure("是否解锁\n"):
|
|
|
|
|
|
|
|
return
|
|
|
|
card = check.isCardInfoSure(self.cards)
|
|
|
|
card = check.isCardInfoSure(self.cards)
|
|
|
|
index = self.cards.index(card)
|
|
|
|
index = self.cards.index(card)
|
|
|
|
self.cards[index].cardLock = "False"
|
|
|
|
self.cards[index].cardLock = "False"
|
|
|
@ -153,23 +164,21 @@ class ATM(object):
|
|
|
|
|
|
|
|
|
|
|
|
print("解锁成功!")
|
|
|
|
print("解锁成功!")
|
|
|
|
time.sleep(1)
|
|
|
|
time.sleep(1)
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 改密
|
|
|
|
# 改密
|
|
|
|
def changePassword(self):
|
|
|
|
def changePassword(self):
|
|
|
|
|
|
|
|
if not check.isSure("是否改密\n"):
|
|
|
|
|
|
|
|
return
|
|
|
|
card = check.isCardInfoSure(self.cards)
|
|
|
|
card = check.isCardInfoSure(self.cards)
|
|
|
|
if check.isCardLock(self.cards, card.cardN):
|
|
|
|
if check.isCardLock(self.cards, card.cardN):
|
|
|
|
return
|
|
|
|
return
|
|
|
|
newpassword = input("请输入新密码")
|
|
|
|
newpassword = input("请输入新密码:")
|
|
|
|
index = self.cards.index(card)
|
|
|
|
index = self.cards.index(card)
|
|
|
|
self.cards[index].cardPassword = newpassword
|
|
|
|
self.cards[index].cardPassword = newpassword
|
|
|
|
self.writeCard()
|
|
|
|
self.writeCard()
|
|
|
|
|
|
|
|
|
|
|
|
print("改密成功!")
|
|
|
|
print("改密成功!")
|
|
|
|
time.sleep(1)
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 写入文件
|
|
|
|
# 写入文件
|
|
|
|
def writeCard(self):
|
|
|
|
def writeCard(self):
|
|
|
|
self.appendCard.append('', mode='w')
|
|
|
|
self.appendCard.append('', mode='w')
|
|
|
|