CodingNic

Object-Oriented Programming

OOP Projects

Object-Oriented Programming 36 min read

OOP Projects

OOP Projects

Great job learning the core ideas of OOP.

You now know:

  • classes
  • objects
  • attributes
  • methods
  • __init__()
  • multiple objects
  • encapsulation
  • inheritance
  • polymorphism

Now it is time to practice by building projects.

Project 1: Bank Account

Build a bank account class.

Requirements:

  • Class name: BankAccount
  • Use __init__() with:
    • owner
    • balance

Methods:

  • deposit(amount)
  • withdraw(amount)
  • show_balance()

Rules:

  • Do not allow withdrawing more than balance.

Example output:

text
150
Not enough money
150

Project 2: Product Inventory

Build a product system.

Requirements:

  • Class name: Product

  • Attributes:

    • name
    • price
    • stock

Methods:

  • add_stock(amount)
  • sell(amount)
  • show_info()

Rules:

  • Do not sell more than stock.

Example output:

text
Laptop 900 5
Laptop 900 8

Project 3: Animal Sounds

Use inheritance.

Requirements:

  • Parent class: Animal

    • method sound()
  • Child classes:

    • Dog
    • Cat

Each child should override sound().

Example output:

text
Woof
Meow

Project 4: Payment System

Use polymorphism.

Requirements:

Classes:

  • Cash
  • Card
  • MobileMoney

Each class should have:

python
pay()

Different message for each payment type.

Use a list and loop through objects.

Example output:

text
Paid by cash
Paid by card
Paid by mobile money

Project 5: Student Class

Build a student class.

Requirements:

  • Use __init__() with:

    • name
    • score

Methods:

  • show_info()
  • passed()

Rules:

  • 80 or more = Pass
  • Below 80 = Needs Work

Example output:

text
Tom 85
Pass

Final Challenge

Build a Car Rental System.

Requirements:

Parent Class

Vehicle

Attributes:

  • brand
  • price_per_day

Method:

  • show_info()

Child Classes

  • Car
  • Bike

Each child should have method:

python
rent(days)

It should print total price.

Example

text
Toyota 50
Total: 150
Yamaha 20
Total: 40

Real World Use Case

OOP is used in banking apps, games, stores, booking systems, and management software.

Quiz

  1. Why are classes useful?
  2. Why use inheritance?
  3. Why use polymorphism?
  4. Why use methods instead of many separate functions?

Assignment

Choose one project and improve it with extra features.

Summary

You practiced building real programs with classes, objects, inheritance, and polymorphism.