doubly linkedlist

In this project, you will develop code for a scheduling application. Specifically, you will need to implement two classes, Scheduler and ScheduleNode. Scheduler is the “main” class, and it maintains the schedule as a doubly-linked collection of ScheduleNodes. Each ScheduleNode has a name and duration and represents a single event on the schedule. A header for both classes has been provided, and you are not allowed to modify this file.

The program starts with an empty schedule of length 100, to which the user may add (and later cancel) events. As user adds and removes events to the schedule, there are five main challenges your code should overcome:

  • All valid changes (e.g., scheduling a new event during a free period or cancelling an existing event) should be reflected when the schedule is printed. • Scheduling or cancelling events should not change the total length of the schedule. • The schedule should never show two consecutive events (or free periods) with the same name. Instead, consecutive events with the same name should be merged together into a single event with a duration equal to the sum of the original events. • Every event must have a positive (i.e., non-zero) duration. • All allocated ScheduleNodes must be deallocated.
  • 2 Member function descriptions

    The member functions you will need to implement are as follows:

  • bool Scheduler::isAvailable(unsigned start, unsigned duration) const: returns whether the time period from time start to start + duration is free; times are considered free if they occur during a ScheduleNode with name == “FREE”. Valid times are 0–99; the head SchedulerNode is considered to start at time 0, and the next node starts immediately after the previous node ends. Times beyond the Scheduler’s length are not considered free. • void Scheduler::schedule(const string& name, unsigned start, unsigned duration): schedule a new event with the given name and duration at a given time, making sure not to create an invalid schedule (e.g., length 6= 100, consecutive nodes with same name, or 0length node). You may assume that the user has already called isAvailable on the start and duration.
  • 1

  • void Scheduler::free(unsigned start): frees up the time associated with the event that starts at the given time (i.e., sets that time back to FREE), without creating an invalid schedule. Has no effect if the time is already free or no event starts at that time. • void Scheduler::printSchedule() const: prints information for all of the events in the schedule, in the following format:
  • TIME: NAME (DURATION) where TIME represents the start time of the event, NAME the event’s name, and DURATION the length of the event. Note that there are two spaces after the colon and one before the open parenthesis. • Scheduler::~Scheduler(): destroys the Scheduler, freeing all ScheduleNodes. You are not required to implement a copy constructor or copy assignment operator for the Scheduler. • void ScheduleNode::merge(ScheduleNode* other): (Optional) compares this ScheduleNode to its argument (which should be the next or previous node), and combines the two nodes into one with the same name where the length is the sum of the two original nodes. This function is not called by the driver and is totally optional, but you may find it helpful to implement this so that you can use it in other functions.

     
    Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount!
    Use Discount Code "Newclient" for a 15% Discount!

    NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.