E-Learning Platform
Part of the Object Oriented Programming section of Coddy's Dart journey — lesson 107 of 110.
Challenge
EasyLet's build an E-Learning Platform that brings together all the OOP concepts you've mastered throughout this course. You'll create a system that manages users, courses, and enrollments using abstract classes, inheritance, mixins, and encapsulation.
Your platform will be organized across five files:
user.dart: Create an abstractUserclass with private fields for_id(String) and_name(String), with public getters. Include an abstract methodString getRole()that subclasses must implement. OverridetoString()to return[role] name (id)where role comes fromgetRole().student.dart: Create aStudentclass that extendsUser. Students should use aProgressTrackingmixin (defined in this file) that provides a private_completedLessonsinteger (starting at 0) with a getter, and methodscompleteLesson()to increment it andgetProgressReport()that returnsCompleted X lessons. TheStudentclass should implementgetRole()to returnStudent.instructor.dart: Create anInstructorclass that extendsUser. Instructors have a private list_coursesCreated(list of Strings representing course titles). Include a methodcreateCourse(String title)that adds the title to the list and returns the title. ImplementgetRole()to returnInstructor. Add a gettercourseCountthat returns the number of courses created.enrollment.dart: Create anEnrollmentclass that tracks a student's enrollment in a course. It should have astudentId(String),courseName(String), and a private_isCompletedboolean (defaults to false) with a getter. Include a methodmarkComplete()that sets completion to true. OverridetoString()to returnstudentId enrolled in "courseName" - Status: CompletedorStatus: In Progressbased on completion status.main.dart: Bring everything together. Create an instructor (I001,Dr. Smith) and have them create two courses:Dart FundamentalsandAdvanced OOP. Print the instructor and their course count asCourses created: X. Create a student (S001,Alice), print them, then have them complete 3 lessons and print their progress report. Create an enrollment for Alice inDart Fundamentals, print it, mark it complete, and print it again.
Expected output:
[Instructor] Dr. Smith (I001)
Courses created: 2
[Student] Alice (S001)
Completed 3 lessons
S001 enrolled in "Dart Fundamentals" - Status: In Progress
S001 enrolled in "Dart Fundamentals" - Status: CompletedTry it yourself
import 'user.dart';
import 'student.dart';
import 'instructor.dart';
import 'enrollment.dart';
void main() {
// TODO: Create an instructor with id "I001" and name "Dr. Smith"
// TODO: Have the instructor create two courses: "Dart Fundamentals" and "Advanced OOP"
// TODO: Print the instructor (uses toString())
// TODO: Print "Courses created: X" where X is the courseCount
// TODO: Create a student with id "S001" and name "Alice"
// TODO: Print the student
// TODO: Have the student complete 3 lessons (call completeLesson() 3 times)
// TODO: Print the student's progress report
// TODO: Create an enrollment for Alice (S001) in "Dart Fundamentals"
// TODO: Print the enrollment
// TODO: Mark the enrollment as complete
// TODO: Print the enrollment again
}
All lessons in Object Oriented Programming
1Fundamentals of OOP
External FilesLibraries & ImportsIntroduction to OOPClasses vs ObjectsThe this KeywordMethodsInstance VariablesConstructor BasicsRecap - Simple Calculator4Null Safety
Intro to Null SafetyNullable vs Non-NullableThe ? and ! OperatorsLate Keyword & Null SafetyNull-Aware OperatorsNull Safety in ClassesRecap - User Profile System7Abstract Classes & Interfaces
Abstract ClassesAbstract MethodsInterfaces in DartImplicit InterfacesImplementing vs ExtendingMultiple InterfacesRecap - Shape Calculator10Collections & Generics
List, Set, Map OverviewType-Safe CollectionsGeneric ClassesGeneric MethodsGeneric ConstraintsIterable & IteratorRecap - Generic Storage13Advanced OOP Concepts
Composition vs InheritanceExtension MethodsCallable ClassesSealed Classes (Dart 3)Records (Dart 3)Patterns & Matching (3.0)Enums with Methods16Project: Library Management
Project OverviewBook and User Classes2Constructors in Dart
Default ConstructorNamed ConstructorsInitializer ListsConstant ConstructorsFactory ConstructorsRedirecting ConstructorsRecap - Shape Builder5Encapsulation
Public vs Private MembersThe _ Prefix ConventionLibrary-Level PrivacyGetters & Setters DepthInformation HidingRecap - Student Records8Mixins
Introduction to MixinsCreating MixinsUsing Multiple Mixinson Keyword in MixinsMixin vs InheritanceMixin vs InterfaceRecap - Animal System11Special Methods
toString() OverridehashCode & == OverrideComparable Interfacecall() MethodnoSuchMethod OverrideRecap - Custom Collection14Design Patterns Part 1
Intro to Design PatternsSingleton PatternFactory PatternObserver PatternStrategy Pattern3Class Properties
Instance vs Static MembersFinal & Const FieldsLate VariablesStatic Methods & FieldsGetters and SettersRecap - Bank Account Manager6Inheritance
Basic InheritanceThe super KeywordMethod OverridingThe @override AnnotationThe final Class KeywordConstructors & InheritanceRecap - Employee Hierarchy9Polymorphism
Polymorphism BasicsPolymorphism via InterfacesRuntime Type CheckingThe is & as OperatorsCovariant KeywordRecap - Payment Processor