コード例 #1
0
 def test_create_checking_verify_overdraft_limit(self):
     name = 'John Doe'
     number = 12345
     balance = 1500.00
     overdraft = 100
     a = CheckingAccount(name, number, balance, overdraft)
     self.assertEqual(overdraft, a.get_overdraft())
コード例 #2
0
 def test_withdraw_success_03(self):
     name = 'John Doe'
     number = 12345
     balance = 1500.00
     overdraft = 100
     a = CheckingAccount(name, number, balance, overdraft)
     self.assertTrue(a.withdraw(balance + 25.56))
     self.assertAlmostEqual(-25.56, a.get_balance(), 2)
コード例 #3
0
 def test_withdraw_success_02(self):
     name = 'John Doe'
     number = 12345
     balance = 1500.00
     overdraft = 100
     a = CheckingAccount(name, number, balance, overdraft)
     self.assertTrue(a.withdraw(0.01))
     self.assertEqual(balance - 0.01, a.get_balance())
コード例 #4
0
 def test_withdraw_fail_not_enough_money(self):
     name = 'John Doe'
     number = 12345
     balance = 1500.00
     overdraft = 100
     a = CheckingAccount(name, number, balance, overdraft)
     self.assertFalse(a.withdraw(balance + 100.01))
     self.assertEqual(balance, a.get_balance())
コード例 #5
0
ファイル: main_BA.py プロジェクト: coltonjcox30/cs1410
def checking_A():
    check = 1
    #x = round(start_b,2)
    print("Great! I need some information to start:")
    acc_name = input("What is the name of the account holder? ")
    acc_num = input("What is the account number? ")
    start_b = input("What is the starting balance? $")
    od = input("What is the overdraft limit? $")
    user = CheckingAccount(acc_name, float(acc_num), float(start_b), float(od))
    while check == 1:
        checking_Option_menu = input("""What would you like to do?
			[d] Deposit
			[w] Withdraw
			[q] Quit
			Enter an option: """)
        if checking_Option_menu == "d":
            value = input("How much would you like to deposit? $")
            user.deposit_Money(float(value))
            print("Your account balanace is now $" +
                  str(round(user.getBal(), 2)) + ".")

        if checking_Option_menu == "w":
            value = input("How much do you want to withdraw? $")
            user.withdrawl_Money(float(value))
            print("Your account balanace is now $" +
                  str(round(user.getBal(), 2)) + ".")

        if checking_Option_menu == "q":
            print("Your final account balance is $" +
                  str(round(user.getBal(), 2)) + ",have a great day!")
            check = 0
            break
コード例 #6
0
ファイル: customer.py プロジェクト: hvl5451/HW4_New
    def create_account(self, account_type):
        """
        method for creating bank account objects
        constructs instances of the Account subclasses with customer attributes:
            -customer name
            -time of method call
            -a random 7-digit integer
            -type of account; a method argument, determines which subclass of Account is created

        returns the account number and prints a message containing the account number
        """

        rand_num = random.randint(1000000, 10000000)

        if account_type.lower() == "checking":
            #new_account = CheckingAccount (self._name, str(datetime.datetime.now()), random.randint(1000000,10000000), account_type, balance=0.0)
            self._customer_account_list[rand_num] = CheckingAccount(
                self._name,
                str(datetime.datetime.now()),
                rand_num,
                account_type,
                balance=0.0)

        if account_type.lower() == "savings":
            #new_account = SavingsAccount (self._name, str(datetime.datetime.now()),random.randint(1000000,10000000), account_type, balance=0.0)
            self._customer_account_list[rand_num] = SavingsAccount(
                self._name,
                str(datetime.datetime.now()),
                rand_num,
                account_type,
                balance=0.0)
            print("account # is {}".format(rand_num))

        print("account number is {}".format(rand_num))
        return rand_num
コード例 #7
0
 def create_account(self):
     self.holder = 'John'
     self.account_number = 12345
     self.balance = 1500
     self.overdraft_limit = 100
     return CheckingAccount(self.holder, self.account_number, self.balance,
                            self.overdraft_limit)
コード例 #8
0
 def test_create_checking_account(self):
     name = 'John Doe'
     number = 12345
     balance = 1500.00
     overdraft = 100
     a = CheckingAccount(name, number, balance, overdraft)
     self.assertIsInstance(a, CheckingAccount)
     self.assertIsInstance(a, Account)
コード例 #9
0
def main():
    savings_account_01 = SavingsAccount(100)
    print("Saving account balance: $", savings_account_01.get_balance(),
          sep="")

    checking_account_01 = CheckingAccount(500)
    print("Checking account balance: $", checking_account_01.get_balance(),
          sep="")

    print("")

    print("Making deposit into checking account for 75$...")
    checking_account_01.deposit_funds(75)
    print("New checking account balance: $", checking_account_01.get_balance(),
          sep="")

    print("")

    print("Making deposit into savings account for 300$...")
    savings_account_01.deposit_funds(300)
    print("New savings account balance: $", savings_account_01.get_balance(),
          sep="")

    print("")

    transfer_funds(checking_account_01, savings_account_01, 300)
    print("New checking account balance: $", checking_account_01.get_balance(),
          sep="")
    print("New savings account balance: $", savings_account_01.get_balance(),
          sep="")

    print("")
コード例 #10
0
ファイル: manager.py プロジェクト: hvl5451/HW4_New
    def create_account_for_customer(self, c, account_type):
        """creates a new account for customer"""
        account_num = randint(1, 100000000)
        if account_type == "Savings":
            new_account = SavingsAccount(c.get_name(),datetime.date.today().ctime(),\
            account_num, account_type)
        elif account_type == "Checking":
            new_account = CheckingAccount(c.get_name(),datetime.date.today().ctime(),\
            account_num, account_type)

        c.create_account(account_type)
コード例 #11
0
ファイル: main.py プロジェクト: grbalmeida/hello-python
from savings_account import SavingsAccount
from checking_account import CheckingAccount

savings_account = SavingsAccount(1111, 2222, 0)
savings_account.deposit(100)
savings_account.deposit(150)
savings_account.deposit(280)

savings_account.withdraw(10)
savings_account.withdraw(15)
savings_account.withdraw(1000)

checking_account = CheckingAccount(agency=1111,
                                   account_number=3333,
                                   balance=0,
                                   limit=500)

checking_account.deposit(100)
checking_account.withdraw(250)
checking_account.withdraw(260)
checking_account.withdraw(500)
コード例 #12
0
ファイル: main.py プロジェクト: grbalmeida/hello-python
from random import randint
from bank import Bank
from checking_account import CheckingAccount
from savings_account import SavingsAccount
from customer import Customer

bank = Bank()

luiz = Customer('Luiz', 25)
maria = Customer('Maria', 52)

savings_account = SavingsAccount(1111, 32460, 0)
checking_account = CheckingAccount(2222, 32461, 0)

luiz.insert_account_number(savings_account)
maria.insert_account_number(checking_account)

bank.insert_account(savings_account)
bank.insert_customer(luiz)

bank.insert_account(checking_account)
bank.insert_customer(maria)

for customer in [luiz, maria]:
  if bank.authenticate(customer):
    customer.account.deposit(randint(500, 1000))
    customer.account.withdraw(randint(50, 100))
  else:
    print('Unauthenticated customer')