cheryls28 Apr 20th, 2019 (edited) 74 in 31 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #ifndef TASK_H
  2. #define TASK_H
  3. #include <iostream>
  4. using namespace std;
  5. class Task{
  6.     private:
  7.         // These three member variables store the basic information about a task
  8.     string title;
  9.     string location;
  10.         // This pointer will point to a dynamically-allocated array
  11.         // of THREE strings. Each element contains the name of a supply required for this task.
  12.         // This should start out set to NULL.
  13.     string * tags;
  14.         // This integer stores the number of elements in the tags array.
  15.     int numTags;
  16.         // This pointer specifies a "prereq" task, which is a task that
  17.         //  must be completed BEFORE this one.
  18.         // It should start out set to NULL.
  19.     Task * prereqTask;
  22.     public:
  23.         // Constructor: Initializes all instance variables.
  24.         // A newly-created task has no tags and no prereq task.
  25.     Task(string title, string location);
  26.         // Copy constructor: Initializes the current task as a copy of an existing task.
  27.         // - If the existing task has an array of tags, the current
  28.         //     task should end up with its own tags pointer pointing to
  29.         //     a complete copy (newly allocated) of the same array.
  30.     Task(const Task& otherTask);
  31.         // AddTags: Add a set of tags to the task.
  32.         // - You may assume the tagsToAdd array is already filled with string elements,
  33.         //     and the number of elements is given by the size parameter.
  34.         // - This method needs to:
  35.         //   1) PRINT AN ERROR (and do nothing else) if the task already has tags specified
  36.         //   2) Otherwise, allocate a new dynamically allocated array and set its
  37.         //        elements to be copies of the elements in tagsToAdd.
  38.     void AddTags(string tagsToAdd[], int size);
  39.         // AddPrereq: Set the prereq task of the current task.
  40.         // - You may assume otherTask is already set and points to a valid Task object.
  41.         // - This should PRINT AN ERROR if the task already has a prereq.
  42.         // - Otherwise, is must set the prereqTask pointer to point to the same Task object
  43.         //    that otherTask points to.
  44.     void AddPrereq(Task * otherTask);
  45.         // RemovePrereq: Remove the prereq for the current task.
  46.         // - PRINT AN ERROR (and do nothing else) if the current task doesn't have a prerequisite.
  47.         // - Otherwise, set this this task to no longer have a prerequisite.
  48.     void RemovePrereq();
  49.         // Description: Return a short description string for the current Task object.
  50.         // - Including its name, location, a list of tags (if there are any)
  51.         //      and the title of the prereq task (if there is one).
  52.     string Description() const;
  53.         // HasTag: Check if the task has theTag among its set of tags.
  54.         // - If the task has no tags at all, you can return false immediately.
  55.     bool HasTag(string theTag) const;
  56.         // Destructor
  57.         // - This needs to deallocate anything that will no longer be used now that
  58.         //     the current object itself is going away.
  59.         // - Think carefully!! Which things need to be deallocated?
  60.     ~Task();
  62.     friend class TaskList; // Task methods will be accessible to TaskList
  63. };
  64. #endif // TASK_H
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!