Week 5 Assignment

Bank Account System — Object-Oriented Programming

📝 Overview

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:

Accounts live in memory for this week — Week 6 will teach you how to save them permanently using a SQLite database.

Expected Time: 5–6 hours
Difficulty: Medium
Recommended: Week 5 (OOP)

📥 Download Project Files

Click below to download all the files you need to get started:

🎯 Learning Objectives

By completing this assignment, you'll be able to:

  1. Define a class with an __init__ constructor and private attributes
  2. Write and call instance methods that read and modify object state
  3. Use super() to call a parent class method from a subclass
  4. Override methods in subclasses to change behavior without rewriting logic
  5. Use isinstance() to branch on an object's type at runtime
  6. Implement __str__ for clean, readable object printing
  7. Handle invalid operations with descriptive ValueError messages

🏛️ Class Hierarchy

You will build four classes:

Account (base class)

Stores _owner_name, _account_number, and _balance as private attributes. Provides deposit(), withdraw(), get_balance(), and __str__() that both subclasses inherit.

CheckingAccount

Inherits from Account. Withdrawals are unlimited and free. A flat $10.00 monthly maintenance fee is applied by calling apply_monthly_fee().

SavingsAccount

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.

Bank

Manages all accounts in a Python dictionary. Provides create_account(), find_account(), and list_accounts(). A main() function drives the numbered menu loop.

📋 Requirements

Your Bank Account System must support all of the following menu options:

  1. Open new account — ask for the owner's name and account type ("checking" or "savings"), generate a unique account number
  2. Deposit funds — look up the account and add the amount
  3. Withdraw funds — look up the account and deduct the amount, with the correct subclass rules applied
  4. Check balance — print the full account details
  5. List all accounts — show a summary of every open account
  6. Apply monthly fee / interest — checking accounts get the $10.00 fee deducted; savings accounts get 2% interest credited
  7. Quit — exit with a goodbye message

Your program must also:

🚀 Suggested Implementation Order

The scaffolding file has 20 TODO items. Work through them in this order:

  1. TODOs 1–6 — Build the Account base class; create a couple of objects at the bottom of the file and call their methods to test
  2. TODOs 7–9 — Build CheckingAccount; verify the monthly fee deducts correctly
  3. TODOs 10–12 — Build SavingsAccount; test the withdrawal counter and interest calculation
  4. TODOs 13–17 — Build the Bank class
  5. TODOs 18–20 — Wire up the menu and run a full end-to-end test

📁 Files in Your Assignment

💡 Tips for Success

  1. Test each class in isolation. After writing 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.
  2. Use 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.
  3. Let errors bubble up. If super().withdraw() raises a ValueError, it will travel up to main() where your try/except will catch and print it.
  4. Use isinstance() in the menu. When the user picks "Apply fee/interest", check isinstance(account, CheckingAccount) to decide which method to call.
  5. Remember: data resets on restart. That's normal for Week 5 — Week 6 will add SQLite persistence so accounts survive between runs.

🎮 Example Session

=== 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