URGENT: USING C++: You are given a main.cpp and a Schedule.h file. You are to write...

60.1K

Verified Solution

Question

Programming

URGENT:

USING C++:

You are given a main.cpp and a Schedule.h file. You are to write a Schedule.cpp file that implements the missing pieces from Schedule.h.
 
// ************************************
// ************* main.cpp ************
// ************************************
#include \"Schedule.h\"
void main()
{
   Schedule s1(10);
   s1.addEntry(1,20,\"Feed Cat\");
   s1.addEntry(2,40,\"Feed Dog\");
   s1.addEntry(2,50,\"Walk Dog\");
   s1.addEntry(4,0, \"Fix Dinner\");
   s1.addEntry(5,15,\"Eat Dinner\");
   s1.printSchedule();
   Schedule s2(s1); // Note this uses the copy constructor
   cout << endl << \"Output from s2 \" << endl;
   s2.printSchedule();
}
 
 
// **********************************************
// *************  Schedule.h ******************
// **********************************************
#include 
#include 
using namespace std;
 
class Entry{
private:
  int m_hour;
  int m_minute;
  string m_todo;
 
public:
  Entry()
  {
    m_hour = -1;
    m_minute = -1;
    m_todo = \"N/A\";
  }
 
  void setData(int hour, int minute, const char *td);
  void setData(Entry & e); 
 
  //This routine prints a line that would look something like:
  // 12:30 Take a Walk
  void printEntry();
};
 
class Schedule
{
private:
  // Array of Entry
  Entry * m_entryArr;
 
  // Max size of the Array
  int m_maxEntries;
 
  // Number of entries filled in with setData (starts out = 0)
  int m_actualEntryCount;
 
public:
// This Constructor will initialize 2 ints and define the m_entryArr
  Schedule(int maxEntries);
 
// Copy Constructor – it is done for you

    Schedule::Schedule(Schedule & s) {

           m_actualEntryCount =s.m_actualEntryCount;

           m_maxEntries =s.m_maxEntries;

           m_entryArr = newEntry[m_maxEntries];

           for (int i=0; i

           {

               m_entryArr[i].setData(s.m_entryArr[i]);

           }

 }
 ~Schedule();
// addEntry returns true if it succeeds, false if we are out of space
// Note that addEntry will merely call setData to fill in the next entry
// in the array and increment the m_actualEntryCount
   bool addEntry(int hour, int minute, const char *todo);
 
// This routine prints out all entries (i.e. as specified by m_actualEntryCount) 
   void printSchedule();
};

Answer & Explanation Solved by verified expert
4.2 Ratings (708 Votes)
First Complete the getterthat is setData Method for Entry class because we cannot    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students