Project: Bank System

Build a mini banking system from scratch using the OOP skills you have learned. This project brings together inheritance, encapsulation, accessors, aggregation, and dunder methods in one realistic application.

Class Design Overview

┌──────────────────────────┐
│       BankAccount        │
├──────────────────────────┤
│ # _owner                 │
│ # _balance               │
├──────────────────────────┤
│ + deposit(amount)        │
│ + withdraw(amount)       │
│ + get_balance()          │
│ + __str__()              │
└────────────┬─────────────┘
             ↓ inherits
┌──────────────────────────┐
│     SavingsAccount       │
├──────────────────────────┤
│ # _interest_rate         │
├──────────────────────────┤
│ + apply_interest()       │
│ + __str__()              │
└──────────────────────────┘

Bank aggregates accounts (holds a list of references, does not own them).

Hints

  • Use self._balance (protected) throughout
  • Validation in deposit: if amount > 0
  • Validation in withdraw: if amount <= self._balance
  • SavingsAccount.__str__ should show interest rate as a percentage: self._interest_rate * 100
  • Bank.get_account: loop through self._accounts and compare account._owner

Your Task

Implement all the pass stubs in the three classes, then run the test code at the bottom. The check validates the structure and values — not just whether it runs.

Section 1/3Class Design Overview

Class Design Overview

Bank aggregates accounts (holds a list of references, does not own them).

Project: Bank System

Build a mini banking system from scratch using the OOP skills you have learned. This project brings together inheritance, encapsulation, accessors, aggregation, and dunder methods in one realistic application.

Class Design Overview

┌──────────────────────────┐
│       BankAccount        │
├──────────────────────────┤
│ # _owner                 │
│ # _balance               │
├──────────────────────────┤
│ + deposit(amount)        │
│ + withdraw(amount)       │
│ + get_balance()          │
│ + __str__()              │
└────────────┬─────────────┘
             ↓ inherits
┌──────────────────────────┐
│     SavingsAccount       │
├──────────────────────────┤
│ # _interest_rate         │
├──────────────────────────┤
│ + apply_interest()       │
│ + __str__()              │
└──────────────────────────┘

Bank aggregates accounts (holds a list of references, does not own them).

Output:

Click "Check" to run your code.