def main(): # 管理员开机界面 if View.printAdminView(View) == 0: # 死循环,等待用户操作 while True: View.printFunctionView(View) option = input("请输入您的操作:") if option == '1': # 开户 ATM.createUser(ATM) elif option == '2': # 查询 pass elif option == '3': # 取款 pass elif option == '4': # 存款 pass elif option == '5': # 转账 pass elif option == '6': # 改密 pass elif option == '7': # 锁定 pass elif option == '8': # 解锁 pass elif option == '9': # 补卡 pass elif option == '0': # 销户 pass elif option == 'q': # 退出程序 View.quit(View) break else: View.errorQuit(View) time.sleep(1)
def test_authenticate_cardnumber_and_pin_no_bank(self): # start atm atm = ATM() try: atm.authenticate_cardnumber_and_pin(VALID_PIN) except Exception as exp: self.assertEqual(exp.args[0], "No bank linked to ATM")
def setUp(self): checking = Account(101) saving = Account(102) self.bank_card = Card([checking, saving]) self.atm = ATM() self.checking = checking self.saving = saving
def test_connect_bank(self): #start atm atm = ATM() # connect bank bank = Bank() self.assertEquals(atm.bank, None) atm.connect_bank(bank) self.assertEquals(atm.bank, bank)
def __init__(self,radius): self.radius = radius self.atmData = atmfile #process here self.freqCounter = FreqCounter() data = pd.read_csv(atmfile,delimiter=";",header=0) for atm in data.itertuples(index=True): atm = ATM(atm.ID,Point(eval(".".join(atm.LAT.split(","))), eval(".".join(atm.LNG.split(",")))),atm.RED,atm.BANCO,atm.DOM_ORIG) ATMFinder.geopoints.append(atm) self.atmTree = BallTree(np.asarray([atm.getLoc().getCoordRad() for atm in ATMFinder.geopoints]), leaf_size=2,metric="haversine")
def test_authenticate_cardnumber_and_pin(self): #start atm atm = ATM() # connect bank bank = Bank() atm.connect_bank(bank) atm.insert_cardnumber(VALID_CARDNUMBER) atm.authenticate_cardnumber_and_pin(VALID_PIN) self.assertEqual(atm.valid_pin, True) atm.authenticate_cardnumber_and_pin(INVALID_PIN) self.assertEquals(atm.valid_pin, False)
def test_get_accounts(self): #start atm atm = ATM() # connect bank bank = Bank() atm.connect_bank(bank) # insert cardnumber atm.insert_cardnumber(VALID_CARDNUMBER) # insert_pin atm.authenticate_cardnumber_and_pin(VALID_PIN) # get accounts atm.get_accounts() self.assertEqual(atm.active_accounts, bank.get_cardnumber_accounts(VALID_CARDNUMBER))
def main(): #管理员对象 admin = Admin() admin.printAdminView() if admin.adminOption(): return -1 #提款机对象 filePath = os.path.join(os.getcwd(), "allUsers.txt") f = open(filePath, "rb") allUsers = pickle.load(f) allUsers = {} atm = ATM(allUsers) while True: admin.printsysFunctionView() #等待用户操作 option = input("请输入您的操作:") if option == "1": #开户 atm.createUser() elif option == "2": atm.searchUserInfo() elif option == "3": atm.getMoney() elif option == "4": print("存款") elif option == "5": print("转账") elif option == "6": print("改密") elif option == "7": ATM.lockUser() elif option == "8": print("解锁") elif option == "9": print("补卡") elif option == "0": print("销户") elif option == "t": if not admin.adminOption(): #将系统中的用户信息保存到文件中 f = open(filePath, "a") pickle.dump(atm.allUsers, f) f.close() return -1 time.sleep(2)
def __init__(self, statement=None): if not statement: statement = Statement() statement.setup() self._record_path = statement._record_path self.statement = statement self.atms = { x: ATM(x, statement.get_statement_by_tid(x)) for x in statement._get_all_funded_tids() }
def test_insert_cardnumber(self): #start atm atm = ATM() # connect bank bank = Bank() atm.connect_bank(bank) atm.insert_cardnumber(VALID_CARDNUMBER) self.assertEquals(atm.active_cardnumber, VALID_CARDNUMBER)
def test_authenticate_cardnumber_and_pin_no_card(self): #start atm atm = ATM() # connect bank bank = Bank() atm.connect_bank(bank) try: atm.authenticate_cardnumber_and_pin(VALID_PIN) except Exception as exp: self.assertEqual(exp.args[0], "No card in ATM")
def main(): #管理员登入登出 view = Admin() while view.Admin_login_exit(): continue Atm = ATM() while True: view.Sys_Func() option = input('请选择你需要的操作:') if option == '1': #开户 Atm.CreateUser() elif option == '2': #查询 Atm.SearchUserInfo() elif option == '3': #存款 pass elif option == '4': #取款 pass elif option == '5': #转账 pass elif option == '6': #修改密码 pass elif option == '7': #锁定 Atm.LockUser() elif option == '8': #解锁 Atm.UnLocking() elif option == '9': #补卡 pass elif option == '10': #销户 pass elif option == 'exit': #退出 if not view.Admin_login_exit(): return -1
# You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ATM import ATM # ---------------------------------------------------------- # Initialize the ATM # ---------------------------------------------------------- atm = ATM() account = None # account for processing # ---------------------------------------------------------- # Access point: get user pin # ---------------------------------------------------------- pin = atm.get_input("Enter your pin and press [enter] to continue: ") # ---------------------------------------------------------- # Validation: check pin # Give user three(3) tries to get it correct # ---------------------------------------------------------- tries = 0 while tries <= 2: if atm.validate_pin(pin):
def main(): # 欢迎页面 admin = Admin() # 欢迎页面 admin.printWelcomeView() if admin.adminOption(): return -1 # 提款机对象 # 将当前的系统中的用户信息保存到文件中 filePath = os.path.join(os.getcwd(), 'allusers.txt') file = open(filePath, 'rb') allUsers = pickle.load(file) print('******************************') print(allUsers) # ATM对象 atm = ATM(allUsers) while True: # 功能页面 admin.printFunctionView() # 登陆成功, 等待用户操作 option = input('请输入您的操作:') if option == '1': atm.creatUser() elif option == '2': atm.searchUserInfo() elif option == '3': atm.getAccountMoney() elif option == '4': atm.saveMoney() elif option == '5': atm.transformAccountMoney() elif option == '6': atm.reviseAccountPassword() elif option == '7': atm.lockAccount() elif option == '8': atm.unlockAccount() elif option == '9': atm.reserAccountCard() elif option == '0': atm.removeAccount() elif option == 't': # 将当前系统中的用户信息保存到文件中 file1 = open(filePath, 'wb') pickle.dump(atm.allUsers, file1) file1.close() time.sleep(2) print('退出成功') return -1
from ATM import ATM #From ATM.py import ATM class print('Welcome to the ATM machine of your very own bank! Lets get started...' ) #Outputs intro to bank program print('') #space bankName = input( 'Please enter your bank name: ' ) #Asks user for bank name and inputs it into the variable bankName balance = float( input('Please enter your starting balance: $') ) #Asks user for starting balance and inputs it as a float to the variable balance myAtm = ATM( bankName, balance) #Instantiates myAtm sending bankName and balance as paramaters done = False #Sets variable done to False while not done: #While done = False keep running loop print('Please select from the following menu:') #Prints bank menu options print('1 - Display Balance') print('2 - Deposit Money') print('3 - Withdraw Money') print('4 - Add Daily Interest') print('5 - Exit') print(' ') choice = int( input('Type in the number associated with your choice: ') ) #Asks user to choose an option and store as an integer in variable choice
def test_get_accounts_invalid_card_and_pin(self): #start atm atm = ATM() # connect bank bank = Bank() atm.connect_bank(bank) # no card inserted try: atm.get_accounts() except Exception as exp: self.assertEqual(exp.args[0], "No card in ATM") # insert cardnumber atm.insert_cardnumber(VALID_CARDNUMBER) # insert_pin atm.authenticate_cardnumber_and_pin(INVALID_PIN) try: atm.get_accounts() except Exception as exp: self.assertEqual(exp.args[0], "Invalid card/pin") # active_accounts should be empty self.assertEqual(atm.active_accounts, {})
from Person import Person from ATM import ATM bola = Person() bola.height = 2.45 bola.weight = 25 bola.age = 19 #print(bola.calculate_BMI()) #print(bola.calculate_calories()) #khvmv,v #print(bola.healthy_weigh()) #print(bola.calculate_ideal_weight()) me = ATM() me.check_balance() me.add_money(300) me.check_balance() me.withraw(400) me.check_balance()
print(' ') else: print('Error: Please type in a valid number') #This is the second file where the instructions and interaction is from ATM import ATM print('Welcome to the ATM machine of your very own bank! Lets get started...') print('') bankName = input('Please enter your bank name: ') balance = float(input('Please enter your starting balance: $')) myAtm = ATM(bankName, balance) #How to INSTANTIATE??????? done = False while not done: print('Please select from the following menu:') print('1 - Display Balance') print('2 - Deposit Money') print('3 - Withdraw Money') print('4 - Add Daily Interest') print('5 - Exit') print(' ') choice = int(input('Type in the number associated with your choice: ')) if choice == 1: myAtm.displayBalance() #How do I run functions from
def main(): #管理员开机 view = View() view.printAdminView() if view.admin1(): return -1 abspath = os.getcwd() filepath1 = os.path.join(abspath, r'allusers.txt') filepath2 = os.path.join(abspath, r'userinfos.txt') f1 = open(filepath1, 'r+') r1 = f1.readlines() f2 = open(filepath2, 'r+') r2 = f2.readlines() #print(b) #print(type(b)) allusers = json.loads(r1[0]) #读出来是一个字典 userinfos = json.loads(r2[0]) #print('***') #allusers={} #userinfos={} atm = ATM(allusers, userinfos) while True: view.sysFunctionView() #等待用户操作 option = input('请输入您的操作:') if option == '1': atm.createuser() if option == '2': atm.serchuserinfo() if option == '3': atm.withdrawls() if option == '4': atm.savemoney() if option == '5': atm.transer() if option == '6': atm.changepasswd() if option == '7': atm.lockuser() if option == '8': atm.unlockuser() if option == '9': atm.newcard() if option == '10': atm.killuser() if option == 't': if not view.admin1(): # 将当前用户信息保存在文件中 f1 = open(filepath1, 'w+') f1.write(json.dumps(atm.alluser, ensure_ascii=False)) f1.close() f2 = open(filepath2, 'w+') f2.write(json.dumps(atm.userinfo, ensure_ascii=False)) f2.close() #print(atm.alluser) #print(type(atm.alluser)) return -1 time.sleep(2)
from ATM import ATM from bank import Bank ''' J. Salfity, October 2020 Bank APIs implemented with fake bank data This file simulates an ATM UI and calls the ATM API ''' if __name__ == "__main__": # create bank bofa = Bank() # create atm and connect to bank atm = ATM() atm.connect_bank(bofa) session_restart = False while (atm.power): # user canceled something, opt to end session if session_restart: print("End Session (1/0)?") end = int(input()) if end: atm.end_session() print("SESSION ENDED") session_restart = False # a new session
def main(): lstObj = {} lstATMObj = {} print("1.Account Related transactions.") print("2.ATM related transactions.") print("3.EXIT.") ch = input("Enter choice:") while 3 != ch: if 1 == ch: print("1.Create Account.") print("2.Deposit Amount.") print("3.Withdraw Amount.") print("4.Check Balance.") print("5.EXIT.") ch = input("Enter choice:") while 5 != ch: if 1 == ch: iWantCard = input("Do you want card(0/1)??:") obj = BankBranch() iAccnt = obj.CreateAccount(iWantCard) lstObj[iAccnt] = obj print("Your account number is:{}".format(iAccnt)) bWantCard = True if 0 == iWantCard: bWantCard = False objATM = ATM() iCardnum = objATM.ApplyCard(iAccnt, bWantCard) if True == bWantCard: lstATMObj[iCardnum] = objATM else: lstATMObj[iCardnum] = False print("Your card number is:{}".format(iCardnum)) elif 2 == ch: iAccountNum = input("Please enter account number:") if iAccountNum in lstObj: lstObj[iAccountNum].DepostAmt(iAccountNum, 10) else: print("Invalid account number.") elif 3 == ch: iAccountNum = input("Please enter account number:") if iAccountNum in lstObj: lstObj[iAccountNum].WithdrawAmt(iAccountNum, 10) else: print("Invalid account number.") elif 4 == ch: iAccountNum = input("Please enter account number:") if iAccountNum in lstObj: print lstObj[iAccountNum].CheckBalance(iAccountNum) else: print("Invalid account number.") elif 5 == ch: break ch = input("Enter choice:") elif 2 == ch: print("1.Deposit Amount.") print("2.Withdraw Amount.") print("3.Check Balance.") print("4.Mini Statement.") print("5.EXIT.") ch = input("Enter choice:") while 5 != ch: if 1 == ch: iCardNumber = input("Please enter card number:") if iCardNumber in lstATMObj: lstATMObj[iCardNumber].DepositATM(iCardNumber, 100) else: print("Invalid card number.") elif 2 == ch: iCardNumber = input("Please enter card number:") if iCardNumber in lstATMObj: lstATMObj[iCardNumber].WithdrawATM(iCardNumber, 100) else: print("Invalid card number.") elif 3 == ch: iCardNumber = input("Please enter card number:") if iCardNumber in lstATMObj: print("Balance is:{}".format( lstATMObj[iCardNumber].BalanceATM(iCardNumber))) else: print("Invalid card number.") elif 4 == ch: iCardNumber = input("Please enter card number:") if iCardNumber in lstATMObj: print("Mini Stmt:{}".format( lstATMObj[iCardNumber].ministmt(iCardNumber))) else: print("Invalid card number.") elif 5 == ch: break ch = input("Enter choice:") elif 3 == ch: break print("1.Account Related transactions.") print("2.ATM related transactions.") print("3.EXIT.") ch = input("Enter choice:")
def test_atm_get_last_funding_date(statement): tid = "9V26722D" atm = ATM(tid, statement.get_statement_by_tid(tid)) assert atm.get_last_funding_date() == datetime.datetime.strptime("03/20/2019","%m/%d/%Y")
def ATMsystem(): while True: admin1 = admin('ADMIN', '123') m = admin1.login() if m == 'ok': filepath = os.path.join(os.getcwd(), 'AllUserlist.txt') f = open(filepath, 'rb') Userlist = pickle.load(f) f.close() ATM1 = ATM(Userlist) print('ATM系统当前账户有:') print([x for x in ATM1.userlist]) print('正在进入ATM系统界面!请稍候...') time.sleep(2) while True: admin1.choiceUI() c = input('请输入功能选项:') if c == '1': #建户 ATM1.creataccount() time.sleep(2) elif c == '2': ATM1.serach() time.sleep(2) elif c == '3': ATM1.savemoney() time.sleep(2) elif c == '4': ATM1.reducemoney() time.sleep(2) elif c == '5': ATM1.transfer() time.sleep(2) elif c == '6': ATM1.changepassword() time.sleep(2) elif c == '7': ATM1.lock() time.sleep(2) elif c == '8': ATM1.unlock() time.sleep(2) elif c == '9': ATM1.deleteAccount() time.sleep(2) elif c == 'Q': filepath = os.path.join(os.getcwd(), 'AllUserlist.txt') f = open(filepath, 'wb') pickle.dump(ATM1.userlist, f) f.close() print('正在保存用户信息并退出!请稍候...') time.sleep(1) print('退出至管理员登录界面成功!') break else: print('输入有误,请重新输入!') time.sleep(1) if m == 'exit': print('正在退出程序!请稍候...') time.sleep(2) break
from Account import Account from ATM import ATM userAccount = Account(132131512135) objATM = ATM(userAccount) objATM.showMenu()
class TestAccount(unittest.TestCase): def setUp(self): checking = Account(101) saving = Account(102) self.bank_card = Card([checking, saving]) self.atm = ATM() self.checking = checking self.saving = saving def deposit_50(self): self.atm.perform_request(2,50) def withdraw_20(self): self.atm.perform_request(3,20) def test_account_starts_with_0(self): self.assertEqual(self.checking.balance, 0) self.assertEqual(self.saving.balance, 0) def test_deposit(self): atm = self.atm bank_card = self.bank_card atm.insert_card(bank_card) atm.validate_pin("123") atm.select_account(101) self.deposit_50() balance = self.checking.balance self.assertEqual(balance, 50) def test_withdraw(self): atm = self.atm bank_card = self.bank_card atm.insert_card(bank_card) atm.validate_pin("123") atm.select_account(102) self.withdraw_20() balance = self.saving.balance self.assertEqual(balance, -20) def test_deposit_50_and_withdraw_20(self): atm = self.atm bank_card = self.bank_card atm.insert_card(bank_card) atm.validate_pin("123") atm.select_account(101) atm.perform_request(2, 50) balance = atm.perform_request(1) self.assertEqual(balance, 50) atm.eject_card() atm.insert_card(bank_card) atm.validate_pin("123") atm.select_account(101) atm.perform_request(3, 20) if atm.perform_request(1) is not 30: raise Exception("withdrawing function doesn't work") atm.select_account(102) atm.validate_pin("123") atm.perform_request(2, 10) balance = atm.perform_request(1) self.assertEqual(balance, 10) def test_withdraw_without_pin_throws_error(self): atm = self.atm bank_card = self.bank_card atm.insert_card(bank_card) with self.assertRaises(RuntimeError) as e: atm.select_account(101) self.assertEqual(type(e.exception), RuntimeError)
def test_process_invalid_transaction(self): #start atm atm = ATM() # connect bank bank = Bank() atm.connect_bank(bank) # insert cardnumber atm.insert_cardnumber(VALID_CARDNUMBER) # insert_pin atm.authenticate_cardnumber_and_pin(VALID_PIN) # get accounts atm.get_accounts() for acc in INVALID_ACCOUNTS: try: atm.process_transaction(acc, VALID_REQUESTS[0], 0) except Exception as exp: self.assertEqual(exp.args[0], "Invalid Account") for req in INVALID_REQUESTS: try: atm.process_transaction(VALID_ACCOUNTS[0], req, 0) except Exception as exp: self.assertEqual(exp.args[0], "Invalid Request") amount = -50 try: transaction = atm.process_transaction(VALID_ACCOUNTS[1], 'withdraw', amount) except Exception as exp: self.assertEqual(exp.args[0], "Transaction Denied") try: transaction = atm.process_transaction(VALID_ACCOUNTS[1], 'deposit', amount) except Exception as exp: self.assertEqual(exp.args[0], "Transaction Denied")
def test_process_valid_transaction(self): #start atm atm = ATM() # connect bank bank = Bank() atm.connect_bank(bank) # insert cardnumber atm.insert_cardnumber(VALID_CARDNUMBER) # insert_pin atm.authenticate_cardnumber_and_pin(VALID_PIN) # get accounts atm.get_accounts() # show balance transaction = atm.process_transaction(VALID_ACCOUNTS[0], 'show_balance', 0) self.assertEqual(transaction['start_balance'], transaction['end_balance']) self.assertEqual(atm.transaction_history[-1], transaction) amount = 50 # withdraw transaction = atm.process_transaction(VALID_ACCOUNTS[0], 'withdraw', amount) self.assertEquals(transaction['end_balance'] + amount, transaction['start_balance']) self.assertEqual(atm.transaction_history[-1], transaction) # deposit transaction = atm.process_transaction(VALID_ACCOUNTS[0], 'deposit', amount) self.assertEquals(transaction['end_balance'] - amount, transaction['start_balance']) self.assertEqual(atm.transaction_history[-1], transaction)
def main(): # 界面对象 admin = Admin() # 管理员开机 admin.AdminView() if admin.Check(): return -1 # 存储信息的文件是否存在 if os.path.exists("userinfo.txt"): filepath = "userinfo.txt" else: open("userinfo.txt", "wb") filepath = "userinfo.txt" # 如果存储信息的文件非空 if os.path.getsize(filepath): f = open(filepath, "rb") allusers = pickle.load(f) else: allusers = {} # 在登陆时,打印所有银行储户 # print((allusers)) # 提款机对象 atm = ATM(allusers) while True: admin.FunctionView() # 等待用户操作 option = input("请输入您的操作:") if option == '1': # 开户 atm.CreatUser() elif option == '2': # 查询 atm.searchUserInfo() elif option == '3': # 取款 atm.getMoney() elif option == '4': # 存款 atm.saveMoney() elif option == '5': # 转账 atm.transferMoney() elif option == '6': # 改密码 atm.changePasswd() elif option == '7': # 锁定 atm.lockUser() elif option == '8': # 解锁 atm.unlockUser() elif option == '9': # 补卡 atm.newCard() elif option == '10': # 销户 atm.killUser() elif option == '0': # 退出 if not admin.Check(): # 将当前系统中的用户信息保存到文件中 f = open(filepath, "wb") # pickle 序列化后的数据,可读性差,提高安全性 pickle.dump(atm.allUsers, f) f.close() return -1 time.sleep(1)