Question: You are to write a C++ program which will build and maintain a dynamically allocated linked list of dates and times (could be used in

You are to write a C++ program which will build and maintain a dynamically allocated linked list of dates and times (could be used in implementing an appointment book or similar application). You are given a class for a time (ClockType) and for a date (DateType). You will need to complete the EqualTo function for DateType and LaterThan functions for both ClockType and DateType the others are already complete. You should not use a linked list class unless you write your own.

Processing:

Read from the file dates-times.txt a series of lines of data, each containing a date and a time. Search the existing list for a match on the input date and time combination. If the date-time combination is not already in the list, it should be added where it logically belongs in sequential order. If the date-time combination is already in the list, it should be deleted. At the end of the program, print the resulting list (for debugging purposes, Id recommend printing the list after each insertion or deletion).

Input:

file dates-times.txt can be downloaded from the Program Assignments folder

Line 1: int number of lines of data which follow

Lines 2- : DateType a date in the format m-dd or mm-dd

ClockType a time in the format h:mm or hh:mm

The integer in the first line tells how many lines of data follow.

Input Data File

11 3-10 10:30 4-01 14:10 3-10 11:45 11-22 9:15 7-04 6:45 3-10 11:45 1-31 13:00 3-11 8:00 1-31 12:15 12-25 6:00 12-25 6:15

Program Template

#include

#include

using namespace std;

classClockType

{

public:

void ReadTime (ifstream&fn);

void PrintTime ();

bool LaterThan (constClockType& right) const;

bool EqualTo (constClockType& right) const;

private: // the variables are now inaccessible by a client program

inthr;

int min;

};

// function implementations

voidClockType :: ReadTime (ifstream&fn)

{

fn>>hr;

fn.get();

fn>> min;

}

boolClockType :: LaterThan (constClockType& right) const

{

// complete this function

}

bool ClockType::EqualTo (constClockType& right) const

{

if (hr == right.hr and min == right.min)

return true;

else return false;

}

voidClockType :: PrintTime ( )

{

if (hr< 10)

cout<< "0";

cout<

if (min < 10)

cout<< "0";

cout<< min;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!