Project: School Management System

Build a school management system that demonstrates all four pillars of OOP: encapsulation (protected attributes, validated setters), inheritance (Student and Teacher extend Person), polymorphism (__str__ on each class), and abstraction (well-defined interfaces for each class).

Class Relationships

          Person
         /      \
     Student   Teacher
         \      /
          Classroom
    ◇─── Teacher (composition: room assigns teacher)
    ◇─── Student (aggregation: students exist independently)

IB Exam Focus Areas

  • Encapsulation: _grade with validation in set_grade
  • Inheritance: both Student and Teacher call super().__init__(name, age)
  • Polymorphism: each class has a unique __str__ output
  • Composition vs Aggregation: teacher is composed into classroom; students are aggregated

Hints

  • set_grade: if grade in self.VALID_GRADES: self._grade = grade
  • remove_student: use a list comprehension to filter out the matching student_id
  • get_class_info: something like f"Room {self.room_number}: {teacher name}, {n} students"

Your Task

Implement all pass stubs. This is the most complex project — work through each class in order: Person → Student → Teacher → Classroom. Test after each class.

Section 1/4Class Relationships

Class Relationships

Explore this concept

Project: School Management System

Build a school management system that demonstrates all four pillars of OOP: encapsulation (protected attributes, validated setters), inheritance (Student and Teacher extend Person), polymorphism (__str__ on each class), and abstraction (well-defined interfaces for each class).

Class Relationships

          Person
         /      \
     Student   Teacher
         \      /
          Classroom
    ◇─── Teacher (composition: room assigns teacher)
    ◇─── Student (aggregation: students exist independently)

Output:

Click "Check" to run your code.