Module Five · Object Oriented Programming
📘 Module Five: Putting It All Together – Building a Complete OOP Program
🌟 Module Introduction
Welcome back, programmer! You have come a long way. In Module One, you learned what Object Oriented Programming is. You learned about objects and classes. In Module Two, you learned how to write classes and create objects in Python. In Module Three, you learned about inheritance and polymorphism. In Module Four, you learned about encapsulation and abstraction.
Now it is time to put everything together. In this module, you will build a complete program using all the ideas you have learned. You will create classes. You will use inheritance. You will use polymorphism. You will protect data with encapsulation. You will simplify with abstraction.
We will build a School Management System. It will have students, teachers, and courses. It will show how OOP makes programs organised and powerful. By the end, you will have a complete program that you can run and be proud of.
We will keep using simple words and lots of examples. Let’s build something amazing!
🎯 Learning Objectives
After you finish this module, you will be able to:
- Review all four pillars of OOP.
- Plan a complete OOP program.
- Create a parent class with common attributes and methods.
- Create child classes with inheritance.
- Override methods to create polymorphism.
- Use encapsulation to protect data.
- Use abstraction to simplify your design.
- Combine all concepts in one program.
- Test and debug your program.
- Understand how OOP is used in real software.
- Avoid common mistakes in large programs.
- Feel proud of your complete OOP program.
📖 Warm-up Story: Emeka and the School Computer
Emeka lived in Abuja. His school had just received new computers. The principal asked Emeka to help create a program to manage student information. Emeka was excited. He had learned about OOP and wanted to use it.
He started by thinking about what a school has. A school has students. A school has teachers. A school has courses. Each of these is an object.
Emeka created a class called Person. It had a name and an age. Then he created a class called Student that inherited from Person. A student also has a class level and scores. Then he created a class called Teacher that also inherited from Person. A teacher also has a subject and a salary.
He used encapsulation to protect the student’s scores. He used abstraction to create a common blueprint for all people. He used polymorphism so that both students and teachers could introduce themselves in their own way.
When he finished, he showed the program to his principal. The principal was amazed. “This program can manage hundreds of students and teachers,” she said. “You have built something truly useful.”
Emeka smiled. He had learned that OOP is not just about writing code. It is about solving real problems in an organised way.
Moral of the story: OOP helps you build big programs by organising them into small, manageable objects.
📚 Main Lessons
Lesson 1: Reviewing the Four Pillars of OOP
Definition: The four pillars of OOP are encapsulation, abstraction, inheritance, and polymorphism.
Why it is important: These are the foundation of all OOP programs.
Simple explanation: Think of a house. Encapsulation is the walls. Abstraction is the door. Inheritance is the foundation. Polymorphism is the rooms that serve different purposes.
Real-life example: A car uses all four pillars. Encapsulation protects the engine. Abstraction hides the engine. Inheritance makes different car models from one design. Polymorphism makes different cars move differently.
School example: A school uses all four pillars. Encapsulation protects student records. Abstraction shows only the timetable. Inheritance creates different types of students. Polymorphism makes different students study differently.
Home example: A kitchen uses all four pillars. Encapsulation protects the fridge. Abstraction hides the cooking process. Inheritance creates different appliances from one design. Polymorphism makes different appliances work differently.
Nigerian example: A market uses all four pillars. Encapsulation protects the goods. Abstraction shows only the prices. Inheritance creates different types of traders. Polymorphism makes different traders sell differently.
Table: The Four Pillars
| Pillar | What it does | Example |
| Encapsulation | Protects data | Private bank balance |
| Abstraction | Hides complexity | Car steering wheel |
| Inheritance | Reuses code | Dog inherits Animal |
| Polymorphism | Many forms | Dog barks, Cat meows |
Mini summary: The four pillars of OOP are encapsulation, abstraction, inheritance, and polymorphism. They work together to make programs organised and powerful.
Lesson 2: Planning Your Program
Definition: Planning means deciding what classes you need and what they will do.
Why it is important: A good plan saves time and prevents confusion.
Simple explanation: Before you write code, think about the objects in your program. What are they? What data do they have? What actions can they do?
Real-life example: Before building a house, you draw a plan.
School example: Before writing an essay, you make an outline.
Home example: Before cooking, you gather ingredients.
Nigerian example: Before sewing a dress, you take measurements.
Illustration:
Plan Your Program
|
V
What objects do I need?
|
V
What data do they have?
|
V
What actions can they do?
|
V
Start Coding!
Mini summary: Planning means deciding what classes you need. Think before you code.
Lesson 3: Designing the Parent Class – Person
Definition: A parent class holds common attributes and methods that child classes will share.
Why it is important: It saves time and keeps code organised.
Simple explanation: Both students and teachers are people. They both have names and ages. They both can introduce themselves. So we create a Person class.
Real-life example: All people have names and ages.
School example: All members of a school have names and ages.
Home example: All family members have names and ages.
Nigerian example: All Nigerians have names and ages.
Example code:
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def introduce(self):
print("Hello, my name is " + self.name + " and I am " + str(self.age) + " years old.")
Illustration:
class Person:
__init__ -> name, age
introduce() -> "Hello, my name is..."
Mini summary: The Person class holds common data and actions for all people.
Lesson 4: Creating the Student Class
Definition: A student is a person who studies. The Student class inherits from Person.
Why it is important: Students have special data (class level, scores) and special actions (study, take exam).
Simple explanation: The Student class gets name and age from Person. It adds class level and scores.
Real-life example: A student has a name, age, class, and scores.
School example: A student in JSS3 has scores in different subjects.
Home example: A child in school has homework and test scores.
Nigerian example: A student in a Nigerian school takes WAEC exams.
Example code:
class Student(Person):
def __init__(self, name, age, class_level):
super().__init__(name, age)
self.class_level = class_level
self.__scores = []
def add_score(self, score):
if 0 <= score <= 100:
self.__scores.append(score)
else:
print("Error: Score must be between 0 and 100.")
def get_average(self):
if len(self.__scores) == 0:
return 0
return sum(self.__scores) / len(self.__scores)
def study(self):
print(self.name + " is studying.")
def introduce(self):
super().introduce()
print("I am in " + self.class_level + ".")
Illustration:
class Student(Person):
__init__ -> name, age, class_level, __scores
add_score() -> adds a score safely
get_average() -> returns average
study() -> "studying"
introduce() -> calls parent + "I am in JSS3"
Mini summary: The Student class inherits from Person. It adds class level, scores, and study methods.
Lesson 5: Creating the Teacher Class
Definition: A teacher is a person who teaches. The Teacher class inherits from Person.
Why it is important: Teachers have special data (subject, salary) and special actions (teach, mark).
Simple explanation: The Teacher class gets name and age from Person. It adds subject and salary.
Real-life example: A teacher has a name, age, subject, and salary.
School example: A maths teacher teaches maths and marks exams.
Home example: A private tutor teaches at home.
Nigerian example: A teacher in a Nigerian school prepares students for exams.
Example code:
class Teacher(Person):
def __init__(self, name, age, subject, salary):
super().__init__(name, age)
self.subject = subject
self.__salary = salary
@property
def salary(self):
return self.__salary
@salary.setter
def salary(self, amount):
if amount > 0:
self.__salary = amount
else:
print("Error: Salary must be positive.")
def teach(self):
print(self.name + " is teaching " + self.subject + ".")
def introduce(self):
super().introduce()
print("I teach " + self.subject + ".")
Illustration:
class Teacher(Person):
__init__ -> name, age, subject, __salary
salary (property) -> getter and setter
teach() -> "teaching"
introduce() -> calls parent + "I teach Maths"
Mini summary: The Teacher class inherits from Person. It adds subject, salary, and teach methods.
Lesson 6: Creating the Course Class
Definition: A course is a subject that students take and teachers teach.
Why it is important: Courses connect students and teachers.
Simple explanation: A course has a name, a teacher, and a list of students.
Real-life example: A maths course has a teacher and many students.
School example: JSS3 Maths is a course with Mr Bello and 30 students.
Home example: A cooking class has a teacher and students.
Nigerian example: A WAEC preparation course has a teacher and students.
Example code:
class Course:
def __init__(self, name, teacher):
self.name = name
self.teacher = teacher
self.students = []
def add_student(self, student):
self.students.append(student)
print(student.name + " has been added to " + self.name + ".")
def show_details(self):
print("Course: " + self.name)
print("Teacher: " + self.teacher.name)
print("Students: " + str(len(self.students)))
Illustration:
class Course:
__init__ -> name, teacher, students
add_student() -> adds a student
show_details() -> prints course info
Mini summary: The Course class connects students and teachers. It has a name, a teacher, and a list of students.
Lesson 7: Using Inheritance and Polymorphism
Definition: Inheritance lets Student and Teacher share code from Person. Polymorphism lets them introduce themselves differently.
Why it is important: It makes the program flexible and organised.
Simple explanation: Both students and teachers can introduce themselves. But students say “I am in JSS3” and teachers say “I teach Maths”.
Real-life example: Both doctors and nurses are people. They introduce themselves differently.
School example: Both students and teachers are people. They introduce themselves differently.
Home example: Both children and parents are people. They introduce themselves differently.
Nigerian example: Both traders and customers are people. They introduce themselves differently.
Example code:
people = [
Student("Ada", 14, "JSS3"),
Teacher("Mr Bello", 35, "Maths", 150000),
Student("Tunde", 15, "JSS2"),
Teacher("Mrs Okafor", 40, "English", 180000)
]
for person in people:
person.introduce()
print("---")
Output:
Hello, my name is Ada and I am 14 years old.
I am in JSS3.
---
Hello, my name is Mr Bello and I am 35 years old.
I teach Maths.
---
Hello, my name is Tunde and I am 15 years old.
I am in JSS2.
---
Hello, my name is Mrs Okafor and I am 40 years old.
I teach English.
---
Illustration:
for person in people:
person.introduce()
|
V
Student.introduce() -> "I am in JSS3"
Teacher.introduce() -> "I teach Maths"
Mini summary: Inheritance shares code. Polymorphism lets each object respond in its own way.
Lesson 8: Using Encapsulation to Protect Data
Definition: Encapsulation protects sensitive data like scores and salary.
Why it is important: It prevents accidental changes and errors.
Simple explanation: Scores are private. You can only add them through the add_score method. Salary is private. You can only change it through the salary setter.
Real-life example: A bank protects your balance.
School example: A school protects student records.
Home example: A family protects private documents.
Nigerian example: A bank protects your account details.
Example code:
ada = Student("Ada", 14, "JSS3")
ada.add_score(85)
ada.add_score(90)
ada.add_score(78)
# ada.__scores = [100, 100, 100] # ERROR! Cannot access directly
print("Ada's average: " + str(ada.get_average()))
Output:
Ada's average: 84.33333333333333
Illustration:
Private: __scores
Public: add_score(), get_average()
|
V
Scores are safe!
Mini summary: Encapsulation protects sensitive data. Use private attributes and safe methods.
Lesson 9: Using Abstraction to Simplify
Definition: Abstraction hides complicated details and shows only what is needed.
Why it is important: It makes your program easier to use.
Simple explanation: Users of your program do not need to know how scores are stored. They just call add_score and get_average.
Real-life example: When you drive a car, you do not need to know how the engine works.
School example: When you check your timetable, you do not need to know how it was made.
Home example: When you use a remote, you do not need to know how the TV works.
Nigerian example: When you use an ATM, you do not need to know how the bank’s computers work.
Example code:
# The user does not need to know how scores are stored.
# They just use add_score and get_average.
ada = Student("Ada", 14, "JSS3")
ada.add_score(85)
ada.add_score(90)
print("Average: " + str(ada.get_average()))
Illustration:
User sees:
add_score()
get_average()
User does not see:
__scores list
how average is calculated
Mini summary: Abstraction hides complexity. Users see only what they need.
Lesson 10: Building the Complete Program
Definition: You will now write the complete program.
Why it is important: This is the goal of the module.
Simple explanation: Put all the classes together. Create objects. Use methods. Print results.
Real-life example: A complete school management system.
School example: A program to manage students, teachers, and courses.
Home example: A program to manage family members and chores.
Nigerian example: A program to manage a Nigerian school.
Example code:
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def introduce(self):
print("Hello, my name is " + self.name + " and I am " + str(self.age) + " years old.")
class Student(Person):
def __init__(self, name, age, class_level):
super().__init__(name, age)
self.class_level = class_level
self.__scores = []
def add_score(self, score):
if 0 <= score <= 100:
self.__scores.append(score)
else:
print("Error: Score must be between 0 and 100.")
def get_average(self):
if len(self.__scores) == 0:
return 0
return sum(self.__scores) / len(self.__scores)
def study(self):
print(self.name + " is studying.")
def introduce(self):
super().introduce()
print("I am in " + self.class_level + ".")
class Teacher(Person):
def __init__(self, name, age, subject, salary):
super().__init__(name, age)
self.subject = subject
self.__salary = salary
@property
def salary(self):
return self.__salary
@salary.setter
def salary(self, amount):
if amount > 0:
self.__salary = amount
else:
print("Error: Salary must be positive.")
def teach(self):
print(self.name + " is teaching " + self.subject + ".")
def introduce(self):
super().introduce()
print("I teach " + self.subject + ".")
class Course:
def __init__(self, name, teacher):
self.name = name
self.teacher = teacher
self.students = []
def add_student(self, student):
self.students.append(student)
print(student.name + " has been added to " + self.name + ".")
def show_details(self):
print("Course: " + self.name)
print("Teacher: " + self.teacher.name)
print("Students: " + str(len(self.students)))
# Create teachers
mr_bello = Teacher("Mr Bello", 35, "Maths", 150000)
mrs_okafor = Teacher("Mrs Okafor", 40, "English", 180000)
# Create students
ada = Student("Ada", 14, "JSS3")
tunde = Student("Tunde", 15, "JSS2")
ngozi = Student("Ngozi", 13, "JSS1")
# Add scores
ada.add_score(85)
ada.add_score(90)
ada.add_score(78)
tunde.add_score(70)
tunde.add_score(65)
ngozi.add_score(95)
ngozi.add_score(88)
# Create courses
maths = Course("Mathematics", mr_bello)
english = Course("English", mrs_okafor)
# Add students to courses
maths.add_student(ada)
maths.add_student(tunde)
english.add_student(ada)
english.add_student(ngozi)
# Show all people
print("=== PEOPLE ===")
people = [ada, tunde, ngozi, mr_bello, mrs_okafor]
for person in people:
person.introduce()
print("---")
# Show course details
print("=== COURSES ===")
maths.show_details()
english.show_details()
# Show averages
print("=== AVERAGES ===")
print("Ada: " + str(ada.get_average()))
print("Tunde: " + str(tunde.get_average()))
print("Ngozi: " + str(ngozi.get_average()))
Output:
Ada has been added to Mathematics.
Tunde has been added to Mathematics.
Ada has been added to English.
Ngozi has been added to English.
=== PEOPLE ===
Hello, my name is Ada and I am 14 years old.
I am in JSS3.
---
Hello, my name is Tunde and I am 15 years old.
I am in JSS2.
---
Hello, my name is Ngozi and I am 13 years old.
I am in JSS1.
---
Hello, my name is Mr Bello and I am 35 years old.
I teach Maths.
---
Hello, my name is Mrs Okafor and I am 40 years old.
I teach English.
---
=== COURSES ===
Course: Mathematics
Teacher: Mr Bello
Students: 2
Course: English
Teacher: Mrs Okafor
Students: 2
=== AVERAGES ===
Ada: 84.33333333333333
Tunde: 67.5
Ngozi: 91.5
Illustration:
Person (parent)
|
V
+-------------+ +-------------+
| Student | | Teacher |
| __scores | | __salary |
| add_score() | | teach() |
| get_average()| | introduce() |
+-------------+ +-------------+
| |
V V
Course connects students and teachers
Mini summary: You built a complete school management system using all four pillars of OOP.
Lesson 11: Testing Your Program
Definition: Testing means running your program and checking for errors.
Why it is important: You want your program to work correctly.
Simple explanation: Run the program. Check the output. Try different inputs. Fix any problems.
Real-life example: Before a car is sold, it is tested on the road.
School example: Before an exam, you practise with past questions.
Home example: Before serving food, you taste it.
Nigerian example: Before a wedding, the family does a rehearsal.
Checklist:
- Does the program run without errors?
- Do all methods work?
- Do the scores add correctly?
- Do the averages calculate correctly?
- Do the courses show the right students?
Illustration:
Run Program
|
V
Check Output
|
V
Find Errors
|
V
Fix Errors
|
V
Run Again
|
V
Works! 🎉
Mini summary: Always test your program. Check all parts. Fix any problems.
Lesson 12: Improving Your Program
Definition: Improving means making your program better.
Why it is important: Good programs can always be better.
Simple explanation: You can add more features. You can fix bugs. You can make the code cleaner.
Real-life example: A phone gets updates to add new features.
School example: A student improves their essay after getting feedback.
Home example: You improve a recipe after tasting it.
Nigerian example: A tailor improves a dress after the first fitting.
Ideas for improvement:
- Add more types of people (e.g., Principal, Parent).
- Add more courses.
- Add a method to remove students from courses.
- Add a method to show all scores for a student.
- Add a method to calculate class average.
- Add a method to save data to a file.
Illustration:
Basic Program
|
V
Add Features
|
V
Fix Bugs
|
V
Better Program!
Mini summary: You can always improve your program. Add features. Fix bugs. Make it better.
Lesson 13: OOP in Real Software
Definition: OOP is used in almost all modern software.
Why it is important: Knowing this helps you understand why you are learning OOP.
Simple explanation: Video games, banking apps, social media, and websites all use OOP.
Real-life example: In a game, each character is an object with health, speed, and actions.
School example: A school management system uses objects for students, teachers, and courses.
Home example: A smart home app uses objects for lights, fans, and doors.
Nigerian example: A bank app uses objects for customers, accounts, and transactions.
Illustration:
Real Software
|
V
+--------+ +--------+ +--------+
| Game | | Bank | | Social |
| objects| | objects| | objects|
+--------+ +--------+ +--------+
All use OOP!
Mini summary: OOP is used in games, banking, social media, and many other programs.
Lesson 14: Common Mistakes in Large Programs
Definition: These are mistakes beginners make when building big programs.
Why it is important: Knowing them helps you avoid them.
Simple explanation: Here are some mistakes to watch out for.
List of mistakes:
- Not planning before coding.
- Making classes too big.
- Not using inheritance when it would help.
- Forgetting to test parts of the program.
- Not using encapsulation to protect data.
- Having too many levels of inheritance.
- Not commenting your code.
Illustration:
Bad Program Good Program
+----------------+ +----------------+
| One big class | | Many small |
| No plan | | classes |
| No tests | | Plan first |
+----------------+ +----------------+
Mini summary: Avoid common mistakes. Plan first. Use small classes. Test everything.
Lesson 15: Your Complete OOP Program – Review and Celebrate
Definition: You have built a complete OOP program.
Why it is important: Reviewing helps you remember.
Simple explanation: You used classes, objects, inheritance, polymorphism, encapsulation, and abstraction.
Real-life example: Like finishing a big project.
School example: Like finishing your final year project.
Home example: Like building a piece of furniture.
Nigerian example: Like completing a big tailoring job.
Illustration:
Learn OOP
|
V
Learn Classes & Objects
|
V
Learn Inheritance & Polymorphism
|
V
Learn Encapsulation & Abstraction
|
V
Build Complete Program
|
V
Celebrate 🎉
Mini summary: You built a complete OOP program. You are now an OOP programmer!
📖 Key Vocabulary
| Word | Simple Definition |
| Encapsulation | Keeping data safe inside an object. |
| Abstraction | Hiding complicated details. |
| Inheritance | When one class gets data and methods from another. |
| Polymorphism | “Many forms” – different objects respond to the same action differently. |
| Parent class | The class being inherited from. |
| Child class | The class that inherits. |
| Override | Changing a method in the child class. |
| super() | A function that calls the parent’s method. |
| Private attribute | Data that only the class can access. |
| Getter | A method that returns private data. |
| Setter | A method that changes private data safely. |
| Property | A special way to use getters and setters in Python. |
| Abstract class | A class that cannot be used directly. |
| Test | Running a program to check for errors. |
🔑 Important Concepts
- Four pillars: Encapsulation, abstraction, inheritance, polymorphism.
- Plan first: Think before you code.
- Parent class: Holds common code.
- Child class: Inherits and adds special code.
- Polymorphism: Same action, different results.
- Encapsulation: Protect data with private attributes.
- Abstraction: Hide complexity.
- Test everything: Find and fix errors.
- Improve always: Make your program better.
🧭 Step-by-Step Explanations
How to plan a complete program
- List the objects you need.
- For each object, list its data (attributes).
- For each object, list its actions (methods).
- Find common data and actions. Put them in a parent class.
- Create child classes for special data and actions.
- Use encapsulation to protect sensitive data.
- Use polymorphism to let objects respond differently.
How to build the program
- Write the parent class.
- Write the child classes.
- Write any other classes (e.g., Course).
- Create objects.
- Call methods.
- Test the program.
- Fix any errors.
- Improve the program.
🌍 Real-life Examples
- A school management system with students, teachers, and courses.
- A hospital system with patients, doctors, and appointments.
- A bank system with customers, accounts, and transactions.
- A game with characters, weapons, and levels.
- A shop with products, customers, and orders.
🇳🇬 Nigerian Examples
- A Nigerian school management system with students, teachers, and courses.
- A market system with traders, goods, and customers.
- A bank system with customers, accounts, and transactions.
- A transport system with buses, routes, and passengers.
- A hospital system with patients, doctors, and appointments.
🎈 Fun Examples Children Can Relate To
- A video game with heroes, enemies, and weapons.
- A football team with players, coaches, and matches.
- A pet shop with animals, owners, and toys.
- A school with students, teachers, and classes.
- A family with parents, children, and chores.
🏠 Everyday Examples
- A phone with apps, contacts, and messages.
- A kitchen with appliances, ingredients, and recipes.
- A library with books, members, and loans.
- A shop with products, customers, and orders.
- A hospital with patients, doctors, and appointments.
👨👩👧 Parent Tips
- Encourage your child to plan before coding.
- Ask them to explain their program.
- Help them test their program.
- Celebrate when they finish their project.
- Remind them that OOP is used in real software.
💡 Interesting Facts
- OOP is used in almost all modern software.
- Python is one of the most popular OOP languages.
- Java is another popular OOP language.
- OOP makes it easier to work in teams.
- OOP makes it easier to fix bugs.
🤔 Did You Know?
- Did you know that OOP was invented in the 1960s?
- Did you know that the first OOP language was Simula?
- Did you know that almost all apps use OOP?
- Did you know that OOP makes code easier to reuse?
- Did you know that you can build anything with OOP?
📌 Remember This
- Four pillars: encapsulation, abstraction, inheritance, polymorphism.
- Plan before you code.
- Parent class holds common code.
- Child class inherits and adds special code.
- Polymorphism: same action, different results.
- Encapsulation protects data.
- Abstraction hides complexity.
- Test everything.
- Improve always.
⚠️ Common Mistakes
- Not planning before coding.
- Making classes too big.
- Not using inheritance when it would help.
- Forgetting to test parts of the program.
- Not using encapsulation to protect data.
- Having too many levels of inheritance.
- Not commenting your code.
✅ Best Practices
- Plan before you code.
- Use small, focused classes.
- Use inheritance for “is-a” relationships.
- Use encapsulation to protect data.
- Test each part of your program.
- Comment your code.
- Improve your program over time.
📊 Illustrations, Diagrams, and Tables
Flowchart: Building a Complete OOP Program
Plan the Program
|
V
Create Parent Class
|
V
Create Child Classes
|
V
Add Encapsulation
|
V
Add Polymorphism
|
V
Create Objects
|
V
Test
|
V
Improve
|
V
Celebrate 🎉
Timeline: Your OOP Journey
Module 1: What is OOP?
Module 2: Classes and Objects
Module 3: Inheritance and Polymorphism
Module 4: Encapsulation and Abstraction
Module 5: Complete Program
Now: You are an OOP programmer!
Table: The Four Pillars in Our Program
| Pillar | Where Used | Example |
| Encapsulation | Student.__scores, Teacher.__salary | Private data |
| Abstraction | add_score(), get_average() | Hidden complexity |
| Inheritance | Student(Person), Teacher(Person) | Shared code |
| Polymorphism | introduce() in Student and Teacher | Different results |
Comparison Table: Without OOP vs With OOP
| Feature | Without OOP | With OOP |
| Organisation | Messy | Clean |
| Reuse | Hard | Easy |
| Fixing bugs | Hard | Easier |
| Adding features | Hard | Easier |
| Working in teams | Hard | Easier |
📝 Summary After Every Lesson
Lesson 1: The four pillars of OOP are encapsulation, abstraction, inheritance, and polymorphism.
Lesson 2: Plan your program before you code.
Lesson 3: The Person class holds common data for all people.
Lesson 4: The Student class inherits from Person and adds scores.
Lesson 5: The Teacher class inherits from Person and adds subject and salary.
Lesson 6: The Course class connects students and teachers.
Lesson 7: Inheritance shares code. Polymorphism lets objects respond differently.
Lesson 8: Encapsulation protects sensitive data.
Lesson 9: Abstraction hides complexity.
Lesson 10: You built a complete school management system.
Lesson 11: Always test your program.
Lesson 12: Improve your program over time.
Lesson 13: OOP is used in real software.
Lesson 14: Avoid common mistakes in large programs.
Lesson 15: You built a complete OOP program. You are an OOP programmer!
📦 End-of-Module Summary
In this module, you put everything together. You reviewed the four pillars of OOP: encapsulation, abstraction, inheritance, and polymorphism. You planned a complete program. You created a parent class called Person. You created child classes called Student and Teacher. You created a Course class. You used inheritance to share code. You used polymorphism to let objects introduce themselves differently. You used encapsulation to protect scores and salary. You used abstraction to hide complexity. You built a complete school management system. You tested it and learned how to improve it. You also learned how OOP is used in real software. You are now a complete OOP programmer!
❓ Frequently Asked Questions (10 questions)
- What are the four pillars of OOP? Encapsulation, abstraction, inheritance, polymorphism.
- Why should I plan before coding? To save time and avoid confusion.
- What is a parent class? A class that holds common data and methods.
- What is a child class? A class that inherits from a parent and adds special data and methods.
- What is polymorphism? Different objects responding to the same action in their own way.
- What is encapsulation? Protecting data with private attributes.
- What is abstraction? Hiding complexity and showing only what is needed.
- How do I test my program? Run it and check the output.
- How can I improve my program? Add features, fix bugs, make it cleaner.
- Where is OOP used? In games, banking, social media, and many other programs.
🔗 Matching Exercises
Match the word to its meaning.
| Word | Meaning |
| 1. Encapsulation | A. When one class gets data from another |
| 2. Abstraction | B. Protecting data |
| 3. Inheritance | C. Different objects respond differently |
| 4. Polymorphism | D. Hiding complexity |
| 5. Testing | E. Checking for errors |
Answers: 1-B, 2-D, 3-A, 4-C, 5-E
🧩 Scenario-based Exercises
- You want to create a program about animals. What is the parent class? (Animal)
- You want dogs and cats to speak differently. What do you use? (Polymorphism)
- You want to protect a student’s scores. What do you use? (Encapsulation)
- You want to hide how scores are stored. What do you use? (Abstraction)
- You want to share common code between students and teachers. What do you use? (Inheritance)
👥 Group Activity
Title: Build a Complete Program Together
Instructions: In groups of 3, choose a topic (e.g., hospital, market, transport). Plan the classes. Create a parent class and child classes. Use encapsulation and polymorphism. Write the code together. Test it. Present to the class.
🧑 Individual Activity
Title: My First Complete OOP Program
Instructions: Write a program with a parent class called Shape and child classes Circle, Square, and Triangle. Use abstraction with an abstract area() method. Use polymorphism to call area() on all shapes. Write down what happens.
🛠️ Mini Project
Title: A Complete OOP Project
Instructions: Build a program for a small business (e.g., a shop, a restaurant, a library). Use all four pillars of OOP:
- Create a parent class for common data.
- Create child classes for different types.
- Use encapsulation to protect sensitive data.
- Use polymorphism to let objects behave differently.
- Use abstraction to hide complexity.
Test your program. Present it to the class.
📋 Practical Assignment
Task: Write a short paragraph (5 sentences) explaining what you learned in this module. Then, list three things you found easy and one thing you found hard. Finally, describe your complete program and how it uses the four pillars of OOP.
🔑 Key Takeaways
- The four pillars of OOP are encapsulation, abstraction, inheritance, and polymorphism.
- Plan before you code.
- Parent classes hold common code.
- Child classes inherit and add special code.
- Polymorphism lets objects respond differently.
- Encapsulation protects data.
- Abstraction hides complexity.
- Always test your program.
- Improve your program over time.
- OOP is used in real software.
💬 Classroom Discussion Questions
- Why is planning important before coding?
- How do the four pillars of OOP work together?
- What is the benefit of using inheritance?
- How does encapsulation make programs safer?
- What would you build with OOP?
➡️ Preparation for the Next Module
Congratulations! You have completed all five modules of the Object Oriented Programming course. In the next steps, you can:
- Build more complex programs with OOP.
- Learn about design patterns.
- Explore other OOP languages like Java or C#.
- Contribute to open-source projects.
- Teach others what you have learned.
You are now an OOP programmer. Go and build amazing things! 🚀
End of Module Five · Object Oriented Programming