Hi MTF,
I was working more on understanding classes, and subclasses.
I was able to create this design for an organizer:
Would you be able to help me review it please?
class Organizer {
static startDate() {
const jan1 = new Date(new Date().getFullYear(), 0, 1);
return jan1;
}
static currentDate() {
return new Date();
}
constructor(name, date, time, priority) {
this._name = name;
this._date = date;
this._time = time;
this._priority = priority;
}
numOfDays1() {
const jan1 = Organizer.startDate();
const currentDate = Organizer.currentDate();
const numofdays = Math.floor((currentDate - jan1) / (1000 * 60 * 60 * 24));
console.log(The year is 2024 it has been this many ${numofdays} since January 1st
);
}
numOfDays2() {
const nextCommitment = new Date(this._date);
const currentDate = Organizer.currentDate();
const numofdays2 = Math.floor((nextCommitment - currentDate) / (1000 * 60 * 60 * 24));
console.log(It is ${currentDate} and you have this many ${numofdays2} days till your next appointment!
);
}
static nextCommitment(date) {
return date; // Just returning the date for demonstration
}
priority() {
if (this._priority.includes(“Star”)) {
console.log(${this._name} is a high priority.
);
} else {
console.log(${this._name} is not a priority.
);
}
}
}
class Appointment extends Organizer {
constructor(name, date, time, priority, description) {
super(name, date, time, priority);
this._description = description;
}
priority() {
super.priority();
}
}
// Example usage of Appointment class
let appointment1 = new Appointment(“Meeting”, “2024-02-28”, “10:00pm”, “Star”, “Discuss project details”);
appointment1.priority(); // Output: “Meeting is a high priority.”
Your feedback is much appreciated!!
Wrufff thank you Bello!