Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

// Use the following .H file and driver function prototypes // Write all class f

ID: 656701 • Letter: #

Question

// Use the following .H file and driver function prototypes
// Write all class functions
// Write all driver functions
// Create a driver program to test all functions
// schedule header file
#ifndef SCHEDULE_H
#define SCHEDULE_H
#include "appointment.h"
#include <iostream>
using std::ostream;
const int SCH_ENTRIES = 10;
class schedule {
   public:
   schedule( void); // Default Constructor

   schedule( const char * p); // title only

   schedule( const schedule &); // copy constructor

   bool addtoSchedule(const appointment &); // if full, return false
                               // otherwise place in the schedule and return true

   bool isFull(void) const; // true if no cells left, false otherwise

   void print(ostream &) const; // print all appointments

   void printForSource(long s, ostream &) const;
                                           // print only appointments that match that source

   appointment search( long s) const;
                   // will return a copy of the first appointment found that matches
                   // the source s, if no match, return an appointment with
                   // a source of -1 and a description of "Not Found";

   static void setDateFlag(int);   
   private:
   char title[40]; // title of the schedule
   int count; // number of appointments currently in the schedule
   appointment appointmentArray[SCH_ENTRIES];
   static int dateFlag;
};
#endif

           // Driver program functions

bool keyBoardEnterAppointment( schedule & ); // return true if successful
                                                   // return false if full

bool addFutureAppointment( schedule &, const appointment & e, int d);
                       // return true if successful, false if full
                       // the appointment added has the same source and
                       // desc as the appointment e, but a date of d days later

bool addRecurringAppointment( schedule &, const appointment & e, int cycle, int times);
// return true if successful, false if full
// times will indicate the number of appointments to add
// each appointment added will have the same source and
// desc as the appointment e, but a date of cycle days later
                               // than the previous appointment added to the schedule

schedule::schedule( void)
{
count = 0;
strcpy(title, "");
  
  
}
schedule::schedule( const char * p)
{
// count = p;
// title = p;
strcpy(title, p);
count = 0;
cout << title << endl;
cout << count << endl;
cout << " ---- " << endl;
  
  

}
schedule::schedule( const schedule & other)
{
count = other.count;
strcpy(title, other.title);

}
bool schedule::addtoSchedule(const appointment & tempApoint)
{
if(this->isFull() ){
return false;}
  
else{

appointmentArray[count] = tempApoint;
count++;
  
return true;}
  
  
/*
if(this->count == tempApoint.count){
return *this ;}
else{
return tempApoint;
}*/


}
bool schedule::isFull(void) const
{
if(count == SCH_ENTRIES){
return true;}
else{
return false;}


}
void schedule::print(ostream & out) const
{
//print(out);
for( int i=0; i < count; i++)
appointmentArray[i].print(out, 1);
  
  
// out << ' ' <<apointmentArray[SCH_ENTRIES] << ' ' << dateFlag << endl;

}
void schedule::printForSource(long s, ostream & outs) const
{
// print(outs);
// addtoSchedule << " " << appointmentArray[] << ' ' << dateFlag << endl;

for(int i=0; i < count; i++)
{
if (appointmentArray[i].getSource() == s)
{

print(outs);
}
  
}


}
appointment schedule::search( long s) const
{
// appointment temp;
for (int i = 0; i < count; i++)
{
if (appointmentArray[i].getSource() == s)
{
   return appointment(appointmentArray[i]);
}
}
  
return appointment(-1, "Not found", 1,3,2015);

}
void schedule::setDateFlag(int temp)
{
temp = dateFlag;

}
bool keyBoardEnterAppointment( schedule & tempKey )
  
{
if(tempKey.isFull())
{
return false;
}
else{
appointment temp;
temp.keyBoardInput();

return tempKey.addtoSchedule(temp);

}
  


}
bool addFutureAppointment( schedule & s, const appointment & e, int d)
{
   // return true if successful, false if full
   // the appointment added has the same source and
   // desc as the appointment e, but a date of d days later
appointment temp(e);
  
if(s.isFull())
{
return false;
}
else{
for ( int i = 0; i < d; i++){
temp.incrementDate();
//s.add(temp);
   s.addtoSchedule(temp);}

  
return true;}

}
bool addRecurringAppointment( schedule & sch, const appointment & e, int cycle, int times)
{
// return true if successful, false if full
// times will indicate the number of appointments to add
// each appointment added will have the same source and
// desc as the appointment e, but a date of cycle days later
// than the previous appointment added to the schedule
appointment temp(e);
  
if(sch.isFull())
{
return false;
  
}
else{
  
  
for (int j=1; j<= times; j++) {
addFutureAppointment(sch, temp, j*cycle);
}

return true;}

}
int main()
{
  
schedule a2;
  

return 0;
}

need help on the driver program!!!!

Explanation / Answer

#include <iostream>
#include "List.h"

using namespace std;

void List::runTestDriver()
{
List list;
string cmmd;

while ( cin >> cmmd )
{
if ( cmmd == "add" )
{
int num;
cin >> num;
list.add( num );
}
else if ( cmmd == "answer" )
{
Iterator iter = list.iterator();
int size;
cin >> size;
if ( size != list.size() )
cout << "Error: sizes do not match" << endl;

int *arr = new int[ size ];
int index = 0;
for ( iter.goFirst(); iter.inList(); iter.goNext() )
{
if ( iter.getCurrent() != arr[ index ] )
{
cout << "Error at index " << index << endl;
cout << "Expected " << arr[ index ]
<< " but see " << iter.getCurrent() << endl;
}
index++;
}
}
else
cout << "Invalid command: " << cmmd << endl;
}

}