diff --git a/banksystem/.idea/.gitignore b/banksystem/.idea/.gitignore
new file mode 100644
index 0000000..359bb53
--- /dev/null
+++ b/banksystem/.idea/.gitignore
@@ -0,0 +1,3 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
diff --git a/banksystem/.idea/.name b/banksystem/.idea/.name
new file mode 100644
index 0000000..fb6e260
--- /dev/null
+++ b/banksystem/.idea/.name
@@ -0,0 +1 @@
+银行系统.py
\ No newline at end of file
diff --git a/banksystem/.idea/bankSystem.iml b/banksystem/.idea/bankSystem.iml
new file mode 100644
index 0000000..166d1a6
--- /dev/null
+++ b/banksystem/.idea/bankSystem.iml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/banksystem/.idea/inspectionProfiles/Project_Default.xml b/banksystem/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..deb13da
--- /dev/null
+++ b/banksystem/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/banksystem/.idea/misc.xml b/banksystem/.idea/misc.xml
new file mode 100644
index 0000000..a6f120b
--- /dev/null
+++ b/banksystem/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/banksystem/.idea/modules.xml b/banksystem/.idea/modules.xml
new file mode 100644
index 0000000..1e852db
--- /dev/null
+++ b/banksystem/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/banksystem/__pycache__/admin.cpython-38.pyc b/banksystem/__pycache__/admin.cpython-38.pyc
new file mode 100644
index 0000000..e7a93a8
Binary files /dev/null and b/banksystem/__pycache__/admin.cpython-38.pyc differ
diff --git a/banksystem/__pycache__/atm.cpython-311.pyc b/banksystem/__pycache__/atm.cpython-311.pyc
new file mode 100644
index 0000000..0267fb7
Binary files /dev/null and b/banksystem/__pycache__/atm.cpython-311.pyc differ
diff --git a/banksystem/__pycache__/atm.cpython-38.pyc b/banksystem/__pycache__/atm.cpython-38.pyc
new file mode 100644
index 0000000..d67eef4
Binary files /dev/null and b/banksystem/__pycache__/atm.cpython-38.pyc differ
diff --git a/banksystem/__pycache__/card.cpython-311.pyc b/banksystem/__pycache__/card.cpython-311.pyc
new file mode 100644
index 0000000..7e28669
Binary files /dev/null and b/banksystem/__pycache__/card.cpython-311.pyc differ
diff --git a/banksystem/__pycache__/card.cpython-38.pyc b/banksystem/__pycache__/card.cpython-38.pyc
new file mode 100644
index 0000000..60cf904
Binary files /dev/null and b/banksystem/__pycache__/card.cpython-38.pyc differ
diff --git a/banksystem/__pycache__/check.cpython-311.pyc b/banksystem/__pycache__/check.cpython-311.pyc
new file mode 100644
index 0000000..8579a5b
Binary files /dev/null and b/banksystem/__pycache__/check.cpython-311.pyc differ
diff --git a/banksystem/__pycache__/check.cpython-38.pyc b/banksystem/__pycache__/check.cpython-38.pyc
new file mode 100644
index 0000000..5920825
Binary files /dev/null and b/banksystem/__pycache__/check.cpython-38.pyc differ
diff --git a/banksystem/__pycache__/readAppendCard.cpython-311.pyc b/banksystem/__pycache__/readAppendCard.cpython-311.pyc
new file mode 100644
index 0000000..fbb75be
Binary files /dev/null and b/banksystem/__pycache__/readAppendCard.cpython-311.pyc differ
diff --git a/banksystem/__pycache__/readAppendCard.cpython-38.pyc b/banksystem/__pycache__/readAppendCard.cpython-38.pyc
new file mode 100644
index 0000000..6fa00e3
Binary files /dev/null and b/banksystem/__pycache__/readAppendCard.cpython-38.pyc differ
diff --git a/banksystem/admin.py b/banksystem/admin.py
new file mode 100644
index 0000000..2aae116
--- /dev/null
+++ b/banksystem/admin.py
@@ -0,0 +1,94 @@
+'''
+管理员界面
+类名:View
+属性:账号,密码
+行为:管理员界面 管理员登陆 系统功能界面 管理员注销
+
+系统功能:开户 查询 取款 存储 转账 改密 销户 退出
+'''
+import check
+from check import Check
+import time
+import tkinter as tk
+
+class Admin(object):
+
+ def __init__(self,admin,password):
+ self.admin = admin
+ self.password = password
+
+
+
+ # 管理员界面
+ def window(self):
+ print("*-------------------------------------------------------------*")
+ print("| #### ##### ### ### ## ## ## |")
+ print("* ## ## ## ## ## ## ## ## ## # ## *")
+ print("* ## ## ## ## ## # # ## ## ## ## ## *")
+ print("| #### ## ## ## ## ## ## ## ## # ## |")
+ print("| ## ## ## ## ## # ## ## ## ### |")
+ print("| ## ## ##### ## ## ## ## ## |")
+ print("*-------------------------------------------------------------*")
+ time.sleep(1)
+ return
+
+ #管理员登录界面
+ def login(self):
+ print("*------------------------------------*")
+ print("| |")
+ print("| ## ## ## ## |")
+ print("| ## ## # ## |")
+ print("* ## ## ## ## ## *")
+ print("* ## ## ## # ## *")
+ print("| ## ## ## ### |")
+ print("| ######### ## ## ## |")
+ print("| |")
+ print("*------------------------------------*")
+ check = Check()
+ check.userName(self.admin, self.password)
+ print("*-------------登陆成功---------------*")
+ print(" 正在跳转到系统功能界面,请稍候... ")
+ del check
+ time.sleep(3)
+ return
+
+ # 管理员注销界面
+ def logout(self):
+ print("*-------------------------------------------------------------------------------*")
+ print("| ##### #### ##### ### ### ## ## ## |")
+ print("* ## ## ## ## ## ## ## ## ## ## ## # ## *")
+ print("* ## ## ## ## ## ## ## # # ## ## ## ## ## *")
+ print("| ## ## #### ## ## ## ## ## ## ## ## # ## |")
+ print("| ## ## ## ## ## ## ## # ## ## ## ### |")
+ print("| ##### ## ## ##### ## ## ## ## ## |")
+ print("*-------------------------------------------------------------------------------*")
+ #确认是否注销
+ checkt = Check()
+ if not check.isSure('注销'):
+ return False
+
+ checkt.userName(self.admin,self.password)
+ print("*-------------注销成功---------------*")
+ print(" 正在关闭系统,请稍候... ")
+ del check
+ time.sleep(3)
+
+ return True
+
+ #系统功能界面
+ '''
+ 系统功能:开户,查询,取款,存储,转账,销户,挂失,解锁,改密,退出
+ '''
+ def funcWindow(self):
+ print("*---------Welcome To HG Bank---------*")
+ print("| |")
+ print("| (1)开户 (2)查询 (3)存款 |")
+ print("| |")
+ print("| (4)取款 (5)转账 (6)销户 |")
+ print("| |")
+ print("| (7)挂失 (8)解锁 (9)改密 |")
+ print("| |")
+ print("| (T)退出 |")
+ print("| |")
+ print("*---------Welcome To HG Bank---------*")
+
diff --git a/banksystem/atm.py b/banksystem/atm.py
new file mode 100644
index 0000000..14b463b
--- /dev/null
+++ b/banksystem/atm.py
@@ -0,0 +1,190 @@
+'''
+提款机:
+类名:ATM
+属性:
+行为:开户,查询,取款,存储,转账,销户,挂失,解锁,改密,退出
+'''
+import check
+from check import Check
+from card import Card
+from readAppendCard import ReadCard, AppendCard
+import random
+import time
+
+
+class ATM(object):
+ # 开户 初始化类属性
+ def __init__(self):
+ self.check = Check()
+ self.readCard = ReadCard()
+ self.appendCard = AppendCard()
+ self.cards = self.readCard.read()
+
+ def newAccount(self):
+ # 输入身份证号和手机号
+ pnum = check.phoneNumInput()
+ iden = check.identifyInput()
+ print("正在执行开户程序,请稍候...")
+
+ while True:
+ cardN = str(random.randrange(100000, 10000000))
+ if cardN[0] == '0':
+ continue
+ if not check.isCardNExist(self.cards, cardN):
+ break
+ else:
+ continue
+ # 初始化卡号密码,卡里的钱,卡的锁定状态
+ card = Card(cardN, '000000', 0, iden, pnum, 'False')
+ self.appendCard.append(card)
+ print("开户成功,您的卡号为%s,密码为%s,卡余额为%d。" % (cardN, '888888', 0))
+ print("请牢记密码,不要把密码泄露给他人。")
+ # 更新卡号列表
+ self.cards = self.readCard.read()
+ return True
+
+ # 查询
+ def checkMoney(self):
+ card = check.isCardExist(self.cards)
+ if check.isCardLock(self.cards, card.cardN):
+ return
+ print("您的余额为%d元!" % card.cardMoney)
+ time.sleep(1)
+ return card.cardMoney
+
+ # 存储
+ def saveMoney(self):
+ card = check.isCardExist(self.cards)
+ if check.isCardLock(self.cards, card.cardN):
+ return
+ mon = int(input("请输入您要存的钱:"))
+ index = self.cards.index(card)
+ self.cards[index].cardMoney += mon
+ self.writeCard()
+
+ print("存款成功!您卡上的余额为%d元!" % self.cards[index].cardMoney)
+ time.sleep(1)
+ pass
+
+ # 取款
+ def getMoney(self):
+ card = check.isCardExist(self.cards)
+ if check.isCardLock(self.cards, card.cardN):
+ return
+ mon = int(input("请输入您要取的钱:"))
+ index = self.cards.index(card)
+ if mon > self.cards[index].cardMoney:
+ print("余额不足,您当前余额为%d元!" % self.cards[index].cardMoney)
+ time.sleep(1)
+ return
+ self.cards[index].cardMoney -= mon
+ self.writeCard()
+
+ print("取款成功!你卡上的余额为%d元!" % self.cards[index].cardMoney)
+ time.sleep(1)
+ pass
+
+ # 转账
+ def inMoney(self):
+ card = check.isCardExist(self.cards)
+ if check.isCardLock(self.cards, card.cardN):
+ return
+ while True:
+ cardN = input("请输入对方的账号:")
+ cardOther =check.isCardNExist(self.cards, cardN)
+ if not cardOther:
+ print("账号不存在")
+ if check.isSure("继续转账"):
+ continue
+ else:
+ time.sleep(1)
+ return
+ else:
+ break
+ index = self.cards.index(card)
+ while True:
+ mon = int(input("您当前的余额为%d,请输入要转账的钱:" % self.cards[index].cardMoney))
+ if mon > self.cards[index].cardMoney:
+ print("余额不足,您当前余额为%d元!" % self.cards[index].cardMoney)
+ if check.isSure("继续转账"):
+ continue
+ else:
+ time.sleep(1)
+ return
+ else:
+ self.cards[index].cardMoney -= mon
+ break
+ indexOther = self.cards.index(cardOther)
+ self.cards[indexOther].cardMoney += mon
+ self.writeCard()
+ print("转账成功!你卡上的余额为%d元!" % self.cards[index].cardMoney)
+ time.sleep(1)
+ pass
+
+ # 销户
+ def DAccount(self):
+ card = check.isCardInfoSure(self.cards)
+ if card:
+ self.cards.remove(card)
+ self.writeCard()
+
+ print("销户成功!")
+ time.sleep(1)
+ pass
+
+ # 挂失
+ def hangOutAccount(self):
+ card = check.isCardInfoSure(self.cards)
+ if check.isCardLock(self.cards, card.cardN):
+ return
+ if card:
+ index = self.cards.index(card)
+ self.cards[index].cardLock = "True"
+ self.writeCard()
+
+ print("挂失成功!")
+ time.sleep(1)
+ pass
+
+ # 解锁
+ def unlockAccount(self):
+ card = check.isCardInfoSure(self.cards)
+ index = self.cards.index(card)
+ self.cards[index].cardLock = "False"
+ self.writeCard()
+
+ print("解锁成功!")
+ time.sleep(1)
+ pass
+
+ # 改密
+ def changePassword(self):
+ card = check.isCardInfoSure(self.cards)
+ if check.isCardLock(self.cards, card.cardN):
+ return
+ newpassword = input("请输入新密码")
+ index = self.cards.index(card)
+ self.cards[index].cardPassword = newpassword
+ self.writeCard()
+
+ print("改密成功!")
+ time.sleep(1)
+
+ pass
+
+ # 写入文件
+ def writeCard(self):
+ self.appendCard.append('', w='w')
+ for card in self.cards:
+ self.appendCard.append(card)
+
+ # 退出
+ def exit(self):
+ if check.isSure("退出"):
+ return True
+ else:
+ return False
+ pass
+
+
+
diff --git a/banksystem/card.py b/banksystem/card.py
new file mode 100644
index 0000000..87416a5
--- /dev/null
+++ b/banksystem/card.py
@@ -0,0 +1,15 @@
+'''
+卡:
+类名:Card
+属性:卡号【7位随机】 密码 余额 绑定的身份证号 手机号
+'''
+
+
+class Card(object):
+ def __init__(self, cardN, cardPassword, cardMoney, identityId, phoneNum, cardLock=''):
+ self.cardN = cardN
+ self.cardPassword = cardPassword
+ self.cardMoney = cardMoney
+ self.identityId = identityId
+ self.phoneNum = phoneNum
+ self.cardLock = cardLock
diff --git a/banksystem/cardinfo.txt b/banksystem/cardinfo.txt
new file mode 100644
index 0000000..e69de29
diff --git a/banksystem/check.py b/banksystem/check.py
new file mode 100644
index 0000000..18cf3b2
--- /dev/null
+++ b/banksystem/check.py
@@ -0,0 +1,147 @@
+'''
+验证类:
+用户名、密码、卡号、身份证、手机号验证
+输入确认
+'''
+
+
+def isCardNExist(cards, cardN):
+ for card in cards:
+ if cardN == card.cardN:
+ return card
+ else:
+ return False
+
+
+def isSure(operate):
+ while True:
+ res = input("是否确认%s?【yes/no】" % operate)
+ if res not in ['yes', 'no']:
+ print("输入有误,请重新输入!")
+ continue
+ elif res == 'yes':
+ return True
+ else:
+ return False
+
+
+def isPhoneNum(phonenum):
+ if phonenum[0] != '1':
+ print("输入的手机号开头不为1,请重新输入!")
+ return False
+ elif len(phonenum) != 11:
+ print("输入的手机号长度不对【11位】,请重新输入!")
+ return False
+ elif not phonenum.isdigit():
+ print("输入的手机号必须全部是数字,请重新输入!")
+ return False
+ else:
+ return True
+
+
+def phoneNumInput():
+ while True:
+ pnum = input("请输入您的手机号:")
+ if isPhoneNum(pnum):
+ return pnum
+
+
+def identifyInput():
+ iden = input("请输入您的身份证号:")
+ return iden
+
+
+def isCardExist(cards):
+
+ cardN = input("请输入账号:")
+ password = input("请输入密码:")
+
+ while True:
+ for card in cards:
+ if cardN == card.carN:
+ if password == card.cardPassword:
+ return card
+ else:
+ password = input("密码有误,请重新输入密码:")
+ break
+ else:
+ cardN = input("账号不存在,请重新输入账号:")
+ password = input("请输入密码:")
+
+
+def isCardPasswordSure(newassword, oldpassword):
+
+ if newassword == oldpassword:
+ return True
+ else:
+ return False
+
+
+def isCardInfoSure(cards):
+ # 卡号和密码是否正确
+ card = isCardExist(cards)
+ idenId = identifyInput()
+ pnum = phoneNumInput()
+ while True:
+ if card.identityId == idenId:
+ if card.phoneNum != pnum:
+ print("预留手机号输入不对。")
+ if isSure("继续注销或挂失卡号%s" % card.cardN):
+ pnum = phoneNumInput()
+ continue
+ else:
+ return False
+ else:
+ return card
+ else:
+ print("身份证号输入不对。")
+ if isSure("继续注销或挂失卡号%s" % card.cardN):
+ idenId = identifyInput()
+ continue
+ else:
+ return False
+
+
+def isCardLock(cards, cardN):
+ card = isCardNExist(cards, cardN)
+ if card != False:
+ if card.cardLock == "False":
+ return False
+ else:
+ print("此卡已挂失!")
+ return True
+ else:
+ return "卡号不存在"
+
+
+class Check(object):
+
+ def __init__(self):
+ pass
+
+ # 用户验证
+ def userName(self, admin, password):
+ """
+ :param admin: 用户名
+ :param password: 密码
+ :return:
+ """
+ self.admin = admin
+ self.password = password
+ adminFlag = False
+ admin = input("请输入用户名:")
+ while True:
+ # 如果用户名输对,但密码输错,那么重新输入时只需输入密码验证即可
+ if adminFlag:
+ admin = input("请输入用户名:")
+ password = input("请输入密码:")
+ if admin != self.admin:
+ print("输入的用户名不对,请重新输入!")
+ adminFlag = True
+ continue
+ elif password != self.password:
+ print("输入的密码不对,请重新输入!")
+ adminFlag = False
+ continue
+ else:
+ return
diff --git a/banksystem/readAppendCard.py b/banksystem/readAppendCard.py
new file mode 100644
index 0000000..65702da
--- /dev/null
+++ b/banksystem/readAppendCard.py
@@ -0,0 +1,65 @@
+from card import Card
+import json
+
+
+# 读
+class ReadCard(Card):
+ def __init__(self, cardN='', cardPassword='', cardMoney=0, identityId='', phoneNum='', cardLock=''):
+ Card.__init__(self, cardN, cardPassword, cardMoney, identityId, phoneNum, cardLock)
+
+ def dict2Card(self, d):
+ return self.__class__(d["cardN"], d["cardPassword"], d["cardMoney"], d["identityId"], d["phoneNum"],
+ d["cardLock"])
+
+ def read(self):
+ with open("cardinfo.txt", "r", encoding="utf-8") as fr:
+ cards = []
+ for re in fr.readlines():
+ cards.append(self.dict2Card(eval(re)))
+ return cards
+
+
+# 写
+class AppendCard(Card):
+ def __init__(self):
+ Card.__init__(self, cardN='', cardPassword='', cardMoney=0, identityId='', phoneNum='', cardLock='')
+
+ def card2Dict(self, card):
+ return {"cardN": card.cardN, "cardPassword": card.cardPassword,
+ "cardMoney": card.cardMoney, "identityId": card.identityId,
+ "phoneNum": card.phoneNum, "cardLock": card.cardLock
+ }
+
+ def append(self, card, w='a'):
+ # 清除
+ if w == 'w':
+ with open("cardinfo.txt", "w", encoding="utf-8") as fa:
+ fa.write('')
+ else:
+ with open("cardinfo.txt", "a", encoding="utf-8") as fa:
+ json.dump(card, fa, default=self.card2Dict)
+ fa.write('\n')
+
+
+# 删
+class Del(object):
+ def __init__(self):
+ pass
+
+ def del_(self, cardN):
+ readcard = ReadCard()
+ cards = readcard.read()
+ for card in cards:
+ if cardN == card.cardN:
+ cards.remove(card)
+ break
+ else:
+ print("卡号不存在,请重新输入!")
+ return False
+
+ appendcard = AppendCard()
+ appendcard.append('', w='w')
+ for card in cards:
+ appendcard.append(card)
+ return True
+
diff --git a/banksystem/银行系统.py b/banksystem/银行系统.py
new file mode 100644
index 0000000..3633481
--- /dev/null
+++ b/banksystem/银行系统.py
@@ -0,0 +1,35 @@
+from admin import Admin
+from atm import ATM
+
+admin = Admin("admin",'123456')
+admin.window()
+atm = ATM()
+admin.login()
+
+while True:
+ admin.funcWindow()
+ choice = input("请选择您要办理的业务:")
+ if choice == '1':
+ atm.newAccount()
+ elif choice == '2':
+ atm.checkMoney()
+ elif choice == '3':
+ atm.saveMoney()
+ elif choice == '4':
+ atm.getMoney()
+ elif choice == '5':
+ atm.inMoney()
+ elif choice == '6':
+ atm.DAccount()
+ elif choice == '7':
+ atm.hangOutAccount()
+ elif choice == '8':
+ atm.unlockAccount()
+ elif choice == '9':
+ atm.changePassword()
+ elif choice == 'T':
+ if atm.exit():
+ if admin.logout():
+ break
+ else:
+ print("未有此功能!")