Lab3

Problem: Day-planner. Each entry in your day-planner would have two fields:

1. Time that can be captured as a float. (E.g. 2.0 => 2:00am; 2.5 => 2:30am)

2. Task title that can be captured as an std::string. (E.g. “Prepare for exam”)

Create and maintain a day planner, with the following supported operations:

  • Add a new task to the front of the list. Allow insertion only in the ascending or descending order.
  • Delete a task matching a given time.
  • Insert a new task at an appropriate slot.
  • Print the tasks (you could use overloaded << operator).
  • Delete all tasks.
  • Reverse the ordering of tasks.

Implementing the bold-faced entries in the above list is going to be your responsibility.

A snapshot of your day-planner may look like the following:

TODAY’S TASK LIST

6:00 AM: Wake up

7:00 AM: Go to gym

Copy the starter files from here:

/comp/15/public_html/labs/lab3/problem/

Please implement the following 4 operations:

1. Delete a task matching a given timestamp:

void TaskList::deleteTask(float aTimeStamp);

2. Insert a new task at an appropriate slot. Please pay attention to the order in which the tasks are stored in the list.

void TaskList::insertTask(float aTimeStamp, std::string aTaskTitle);

3. Delete all tasks.

void TaskList::removeAll();

4. Reverse the task list.

void TaskList::reverse();

Expected Output:

Beginning list

TODAY’S TASK LIST

(Descending Order)

8:15 AM – Breakfast

6:45 AM – Exercise

6:00 AM – Wake up

List after deleting the entry at 6.75

TODAY’S TASK LIST

(Descending Order)

8:15 AM – Breakfast

6:00 AM – Wake up

The enforced ordering is Ascending. Invalid entry.

Not doing anything

List after adding a bunch of tasks

TODAY’S TASK LIST

(Descending Order)

10:15 PM – Go to bed

7:00 PM – Data structures class

3:30 PM – Play soccer

11:18 AM – Lunch

9:11 AM – Study data structures

8:15 AM – Breakfast

6:00 AM – Wake up

List after deleting the entry at 15.5

TODAY’S TASK LIST

(Descending Order)

10:15 PM – Go to bed

7:00 PM – Data structures class

11:18 AM – Lunch

9:11 AM – Study data structures

8:15 AM – Breakfast

6:00 AM – Wake up

List after inserting a new entry at 13.5

TODAY’S TASK LIST

(Descending Order)

10:15 PM – Go to bed

7:00 PM – Data structures class

1:30 PM – Go to library

11:18 AM – Lunch

9:11 AM – Study data structures

8:15 AM – Breakfast

6:00 AM – Wake up

List after reversing

TODAY’S TASK LIST

(Ascending Order)

6:00 AM – Wake up

8:15 AM – Breakfast

9:11 AM – Study data structures

11:18 AM – Lunch

1:30 PM – Go to library

7:00 PM – Data structures class

10:15 PM – Go to bed

List after removing all

TODAY’S TASK LIST

(Ascending Order)

No agenda!

Solution: The files are here.