A Java-based Course Management System that allows instructors to build Course Modules. Each module may contain lessons or sub-modules, and both must be treated the same way when displaying details.
Composite Design Pattern - This pattern is perfect for representing part-whole hierarchies where courses contain modules, and modules can contain lessons or other sub-modules.
-
CourseComponent.java - Common interface for all course components
- Defines
showDetails()method that all components must implement
- Defines
-
Lesson.java - Leaf component representing individual lessons
- Contains: name, duration, instructorName
- Cannot contain other components
-
CourseModule.java - Composite component representing course modules
- Can contain multiple lessons or other course modules
- Provides
add()method to build hierarchy
-
Main.java - Demonstration class
- Creates sample course structure
- Shows hierarchical display of course content
# Compile all Java files
javac *.java
# Run the demonstration
java Main=== Course Management System ===
Module: Computer Science Course
Module: Programming Fundamentals
Lesson: Java Basics | Duration: 2 hours | Instructor: Prof. Smith
Lesson: OOP Concepts | Duration: 3 hours | Instructor: Prof. Johnson
Lesson: Data Structures | Duration: 4 hours | Instructor: Prof. Brown
- Uniform Treatment: Both lessons and modules implement the same interface
- Flexibility: Easy to add new component types
- Scalability: Supports unlimited nesting levels
- Simplicity: Client code treats all components uniformly
- Component:
CourseComponentinterface - Leaf:
Lessonclass (cannot contain others) - Composite:
CourseModuleclass (can contain multiple components)
✅ Common interface for course components with showDetails() method
✅ Lesson class with name, duration, and instructor attributes
✅ CourseModule class that can contain lessons or other modules
✅ Sample course module with sub-modules and lessons
✅ Hierarchical display of all course details
✅ Composite Design Pattern implementation
- ✅ Created feature/module-management branch
- ✅ Implemented the coding task (Part B requirements)
- ✅ Added duration and instructorName attributes (for merge conflict simulation)
- ✅ Committed and pushed changes
- ✅ Ready for Pull Request creation
See DataFlowDiagram.md for the Level-1 DFD of the Course Management System.
This project demonstrates the Composite Design Pattern in a real-world scenario of managing hierarchical course structures.