Bank Account System — Object-Oriented Programming
In this assignment, you'll build a command-line Bank Account System using Object-Oriented Programming — your biggest project yet. You will design a real class hierarchy from scratch:
CheckingAccount and a SavingsAccount that
both extend a shared Account base class
withdraw() with its own rules while
reusing the parent's validation
Accounts live in memory for this week — Week 6 will teach you how to save them permanently using a SQLite database.
Click below to download all the files you need to get started:
By completing this assignment, you'll be able to:
__init__ constructor and private attributessuper() to call a parent class method from a subclassisinstance() to branch on an object's type at runtime__str__ for clean, readable object printingValueError messagesYou will build four classes:
Stores _owner_name, _account_number, and _balance as private
attributes. Provides deposit(), withdraw(), get_balance(), and
__str__() that both subclasses inherit.
Inherits from Account. Withdrawals are unlimited and free. A flat
$10.00 monthly maintenance fee is applied by calling apply_monthly_fee().
Inherits from Account. The first 3 withdrawals per month are free; each
additional withdrawal adds a $2.50 fee to that transaction. Calling
apply_interest() adds 2% monthly interest to the balance.
Manages all accounts in a Python dictionary. Provides create_account(),
find_account(), and list_accounts(). A main()
function drives the numbered menu loop.
Your Bank Account System must support all of the following menu options:
Your program must also:
The scaffolding file has 20 TODO items. Work through them in this order:
Account base class; create a couple of
objects at the bottom of the file and call their methods to test
CheckingAccount; verify the monthly fee deducts
correctly
SavingsAccount; test the withdrawal counter
and interest calculation
Bank classbank.py — your main program with 20 TODO markers to guide youcheat_sheet.py — reference patterns for classes, inheritance, polymorphism, and menu
loops
Account, add a few lines at the
bottom of the file to create an account, deposit, and withdraw before you write a single line of the
subclasses.
super() correctly. In withdraw(), calling
super().withdraw(amount) runs the parent's method first, so you don't have to repeat the
validation logic in every subclass.
super().withdraw() raises a ValueError,
it will travel up to main() where your try/except will catch and print it.
isinstance() in the menu. When the user picks "Apply fee/interest", check
isinstance(account, CheckingAccount) to decide which method to call.
=== Welcome to First National Bank === 1. Open new account 2. Deposit funds 3. Withdraw funds 4. Check balance 5. List all accounts 6. Apply monthly fee / interest 7. Quit Choose an option: 1 Owner name: Alice Johnson Account type (checking/savings): savings Account created! Account #ACC-4821 Owner : Alice Johnson Type : SavingsAccount Balance: $0.00 Choose an option: 2 Account number: ACC-4821 Amount: 500 Deposited $500.00. New balance: $500.00 Choose an option: 3 Account number: ACC-4821 Amount: 50 Withdrew $50.00. New balance: $450.00 Choose an option: 6 Account number: ACC-4821 Applying interest at 2.0%... Interest earned: $9.00. New balance: $459.00