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:
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:
Laptop 900 5
Laptop 900 8
Project 3: Animal Sounds
Use inheritance.
Requirements:
-
Parent class:
Animal- method
sound()
- method
-
Child classes:
DogCat
Each child should override sound().
Example output:
Woof
Meow
Project 4: Payment System
Use polymorphism.
Requirements:
Classes:
CashCardMobileMoney
Each class should have:
pay()
Different message for each payment type.
Use a list and loop through objects.
Example output:
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:
Tom 85
Pass
Final Challenge
Build a Car Rental System.
Requirements:
Parent Class
Vehicle
Attributes:
- brand
- price_per_day
Method:
show_info()
Child Classes
CarBike
Each child should have method:
rent(days)
It should print total price.
Example
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
- Why are classes useful?
- Why use inheritance?
- Why use polymorphism?
- 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.