Question
Your job is to complete the Evaluation.js and Question.js files that are enclosed so that conform to the below UML diagrams. Helpful Hints: An array
Your job is to complete the Evaluation.js and Question.js files that are enclosed so that conform to the below UML diagrams.
Helpful Hints:
An array list in JavaScript is simply a regular array
To declare an array: arrayName = [];
To add an item to an array: arrayName.push(value);
To remove item from array by index: arrayName.splice(index, 1);
The ES6+ for-of loop may be useful in this assignment
Evaluation.js
/* Recall: JavaScript does not have true support for abstract classes; therefore, an error should be thrown if there is an attempt to instantiate the class */ class abstractEvaluation {
//Default constructor constructor() { if (this.constructor === abstractEvalaution) { throw new TypeError('Abstract class "abstractEvaluation" cannot be instantiated directly.'); } } /* IMPORTNAT: In JavaScript there are the set and get keywords to denote getter and * setter methods. I have completed an example of each to help assist you. */ //NOTE: start is a Date object set startDate(start){ if(this.startDate >= this.endDate){ throw new Error('start date of an evaluation cannot be greater than or equal to the end date of the evaluation.') } this.startDate = start; } get startDate(){ return this.startDate; } /* TODO: Define the remaining getters and setters as shown in the UML diagram */ //NOTE: Ensure the end date is valid relative to the start date set endDate(end){} get endDate(){} //Note: Weight should be a float greater than 0 and less than or equal to 100 set weight(w){} get weight(){} //Note: total marks is updated in the addQuestion and RemoveQuestion methods get totalMarks(){} //TODO: Implement addQuestion which adds a question to the ArrayList
/* TODO: Implement the below subclasses as defined in the UML diagram*/ export class Quiz extends abstractEvaluation{
}
export class Assignment extends abstractEvaluation{ }
export class Test extends abstractEvaluation{ }
Question.js
class abstractQuestion{ constructor(){ this.question="" this.marks=1 //by default questions are worth 1 mark if (this.constructor === abstractQuestion) { throw new TypeError('Abstract class "abstractQuestion" cannot be instantiated directly.'); } /* NOTE: This defines grade as an abstract class that must be implemented by subclasses */ if (this.grade === undefined) { throw new TypeError('Classes extending abstractQuestion must implement grade()'); } } //TODO: Implement below setters and getters set marks(m){} get marks(){} set question(q){} get question(){} }
export class MultipleChoice extends abstractQuestion{
//TODO: Implement setters and getters from UML diagram
//NOTE: answer in a multiple choice question should be the index of the correct response. // If answer is the correct index return "marks" the question is 0, return 0 otherwise grade(answer){}
}
export class ShortAnswer extends abstractQuestion{
//TODO: Implement setters and getters from UML diagram
//NOTE: answer in a short answer question should be a string. // If answer is the correct index return "marks" the question is 0, return 0 otherwise grade(answer){}
}
export class Ordering extends abstractQuestion{
//TODO: Implement setters and getters from UML diagram
//NOTE: answer in a ordering question should be an array of ints representing the "options" // correctly ordered from start to finish. //EXAMPLE: options = ["Turn on the stove", "Turn off the stove", "Boil water"] // answer = [0,2,1] // If answer is the correct index return "marks" the question is 0, return 0 otherwise grade(answer){}
}
UML diagrams
Design: Evaluation startDate:Date .endDate:Date totalMarks: int -weight: float questions ArrayListStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started