University Management System
Part of the Object Oriented Programming section of Coddy's JavaScript journey — lesson 55 of 56.
Challenge
In this challenge, we have a university system with different types of people (students, professors) who have different roles and behaviors.
1. Complete Person class:
- Add
introduce()method returning"Hi, I'm ${name}"
2. Complete Student class:
- Override
introduce()to return${super.introduce()}, a ${this.major} student. Example: "Hi, I'm Alice, a Computer Science student" - Add
addGrade(grade)method that takes a grade between 0 and 100- Validation: Check if grade is between 0 and 100
- If valid: Add to
this.gradesarray - If invalid: Log:
"Grade must be between 0 and 100"
3. Complete Professor class:
- Override
introduce()to return“Prof. ${name} from ${department}”. Example: “Prof. Smith from Computer Science”
Try it yourself
import { Person } from './person.js';
import { Student } from './student.js';
import { Professor } from './professor.js';
// Create people
const student1 = new Student('Alice', 20, 'Computer Science');
const prof1 = new Professor('Dr. Johnson', 50, 'Mathematics');
console.log(student1.introduce()); // "Hi, I'm Alice, a Computer Science student"
console.log(prof1.introduce()) // "Prof. Dr. Johnson from Mathematics"
student1.addGrade(85);
student1.addGrade(90);
student1.addGrade(95);
console.log(`${student1.name}'s GPA: ${student1.getGPA()}`); // ~3.6
student1.addGrade(105); // Should log: "Grade must be between 0 and 100"All lessons in Object Oriented Programming
1Objects & The this Keyword
Quick Review: ObjectsAdding Methods to ObjectsUnderstanding the this KeywordConstructor FunctionsThe new KeywordRecap Challenge7 Inheritance & The extends Key
InheritanceThe "is-a" RelationshipThe extends KeywordThe super() MethodInheriting Properties&MethodsRecap Challenge2Organizing Code
What are Modules?Exporting with exportImporting with importDefault vs. Named Exports8Organizing OOP Code
Organize Classes into Modules11Project: A Shape Renderer
Setup: Shape Class & ExportCircle Class Inheritance9Static Methods & Properties
Class-Level vs. Instance-LevelStatic PropertiesStatic Utility MethodsRecap challenge12Getters & Setters
The get and set KeywordsComputed PropertiesValidation and Side EffectsRecap Challenge15 Final Challenges
Game Character BuilderE-commerce Product SystemUniversity Management SystemSmart Home Device System