[SOLVED] VE280-Lab 7

30.00 $

Category:

Description

Rate this product

VE 280 Lab 7

Ex.1
Related Topics: virtual function, interface
First of all, in order to hide all implementation details, you decide to realize the ADT Course as a homonym virtual base class in course.h . Regarding the implementation of this base class, you decide that the unfinished tasks are managed with an array tasks .
The three operations of this ADT are defined as follows in the base class:
1 void updateTask(const std::string &type, int index, int dueMonth, int dueDay);
2 // REQUIRES: dueMonth and dueDay are in normal range.
3 // MODIFIES: this 4 // EFFECTS: adds/updates Task index of type; throw exception if fails to add Task
5 void finishTask(const std::string &type, int index, int finishMonth, int finishDay);
6 // REQUIRES: Task index of type exists in tasks. finishMonth and finishDay are in normal range.
7 // MODIFIES: this 8 // EFFECTS: removes Task index of type
9 void print();
10 // EFFECTS: prints all unfinished tasks of this Course
“in normal range” means that there is no date like dueMonth=14 or dueMonth=4, dueDay=31 . In updateTask , if array tasks is full, then you need to throw an exception of the tooManyTasks type, which is a class defined in course.h .
print will print the course code and all elements in tasks in order. The implementation of print is already given to you, please do not modify it.
This ADT is implemented as a derived class TechnicalCourse in course.cpp . It has four protected data members:
1 Task *tasks; // Array of current unfinished tasks 2 int sizeTasks; // Maximum number of unfinished tasks in the array 3 int numTasks; // Number of current unfinished tasks in the array 4 std::string courseCode; // Course code, e.g. “VE280”

When you create a new TechnicalCourse , numTasks should be initialized to 0, courseCode should be initialized according to the input. If the input argument size is specified, sizeTasks should be initialized as size ; otherwise, it should be initialized as the default value MAXTASKS , which is 4.
1 TechnicalCourse(const std::string &courseCode, int size = MAXTASKS);
As for the three methods:
updateTask takes the type , the index , the dueMonth and the dueDay of the task to be
updated as inputs. If the task already exists in the array tasks , you should update its dueMonth and dueDay . If it is a new task, inserts it at the end of tasks and throws an
exception of type tooManyTasks if tasks is full.
After inserting tasks whose type is “Lab” or “Project”, you need to print a message:
1 <courseCode> <type> <index> is released! Submit it via oj!
After inserting tasks of type other than “Lab” and “Project”, you need to print another message:

Example:
1 // ve281 is a pointer to an instance of TechnicalCourse with courseCode “VE281”
2 ve281->updateTask(“Assignment”, 1, 5, 10); 3 ve281->updateTask(“Lab”, 1, 5, 20); 4 ve281->updateTask(“Project”, 1, 5, 30);
5 ve281->updateTask(“Lab”, 1, 5, 15); // no message is printed since it already exists in tasks