コード例 #1
0
ファイル: transactions.py プロジェクト: damilare/python_talk
def withdraw_funds(value, account):
    import pdb
    pdb.set_trace()
    balance = get_balance(account)

    if balance <= 0:
        account = 'overdraft'
        new_balance = handle_overdraft(value)
    else:
        new_balance = handle_withdrawal(account, value)

    print("\t\tYou new {account} balance is {new_balance}\n".format(
        account=account, new_balance=new_balance))
コード例 #2
0
ファイル: main.py プロジェクト: garrettcadams/HackRU_FeedMe
def balance():
	print("Ideally this would be individual for each customer.")
	print("However, since we received only three customer IDs,")
	print("please select whose account do you want to check?")
	print("1. Jerald")
	print("2. Sabrina")
	print("3. Elliott")
	cus = int(input())
	while (cus != 1 and cus != 2 and cus != 3):
		print("I didn't get that, please select again!")
		cus = int(input())
	if cus == 1: balance = bank.get_balance('58fcb3e9a73e4942cdafd565')
	elif cus == 2: balance = bank.get_balance('58fcb3e9a73e4942cdafd566')
	else: balance = bank.get_balance('58fcb3e8a73e4942cdafd564')
	customers = ["Jerald", "Sabrina", "Elliott"]
	if balance == 'na': comment = "you do not have an account. It might be better to save some?"
	elif balance < 10000: comment = "you have less than $10,000. Think twice before splurging!"
	else: comment = "your account's balance is great. Might it be time to treat yourself and your loved ones?"
	print()
	print("Hi " + str(customers[cus-1]) + "! According to our information, " + comment)
	print()
	input("Press any key to continue...")
	print()
	main()
コード例 #3
0
print("**************** print all persons in database****************")
# perform query and get results
result = conn.query('SELECT * FROM person')
for item in result:
    person = item.wrap(bank.Person)
    print("Hi my name is {0.name} with id {0.person_id}".format(person))

print("\n**************** print person that has id = 1 ****************")
# retrieves the person SQL table that has id 1
result = conn.query("select * from person where `person_id` = 1")
first = list(result)[0]
person1 = first.wrap(bank.Person)
print("Person 1 has id {0.name} and has name {0.person_id}".format(person1))

# deposit money into accounts account
result = conn.query("select * from account where `account_id` = 1")
first = list(result)[0]
account1 = first.wrap(bank.Account)
account1 = account1.put(10)

print("\n**************** interface for connecting ****************")
result = input("Enter something\n")

if result == 'deposit':
    account_id = input("\nEnter account id\n")
    amount = input("\n Enter amount to deposit\n")
    bank.deposit(1, amount)
    print("Balance is now: ")
    print(bank.get_balance(account_id=1))
コード例 #4
0
 def test_deposit_money(self):
     bank.deposit_money(100)
     self.assertEqual(100, bank.get_balance())
コード例 #5
0
 def test_get_balance(self):
     self.assertEqual(bank.balance, bank.get_balance())
コード例 #6
0
 def test_withdraw_money(self):
     bank.balance = 100
     bank.withdraw_money(75)
     self.assertEqual(25, bank.get_balance())
コード例 #7
0
 def test_withdraw_money(self):
     bank.balance = 200
     self.assertTrue(bank.withdraw_money(100))
     self.assertEqual(100, bank.get_balance())