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

// NOTES: // 1) We will only add to the schedule, no deletes // 2) Each new add

ID: 653919 • Letter: #

Question

// NOTES:
// 1) We will only add to the schedule, no deletes
// 2) Each new add will be placed after the previous add in the array
// -- count keeps track of the next free cell to use

// 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;
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;
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;
}*/
cout << appointmentArray[0].getDay();
return false;


}
bool schedule::isFull(void) const
{
if(
  


}
void schedule::print(ostream & out) const
{
//print(out);
out << ' ' <<apointmentArray[SCH_ENTRIES] << ' ' << dateFlag << endl;

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

}
appointment schedule::search( long s) const
{
  


}
void schedule::setDateFlag(int)
{

}
bool schedule::keyBoardEnterAppointment( schedule & tempKey )
{


}
bool schedule::addFutureAppointment( schedule &, const appointment & e, int d)
{

}
bool schedule::addRecurringAppointment( schedule &, const appointment & e, int cycle, int times)
{


}
int main()
{

return 0;
}

Explanation / Answer

program :

#ifndef SCHEDULE_H
#define SCHEDULE_H
#include "appointment.h"
#include <iostream>
using std::ostream;
const int SCH_ENTRIES = 10;
class schedule
{
public:
schedule(void);
schedule(const char *p);
bool addtoSchedule(const appointment &);

private:
char title[40];
int count;
appointment appointmentArray[SCH_ENTRIES];
};
schedule::schedule(void)
{
}
schedule::schedule(const char *p)
{
strcpy(title, p);
count = 0;
cout << title << endl;
cout << count << endl;
cout << "----" << endl;
}

bool schedule::addtoSchedule(const appointment & myAppt)
{
cout << appointmentArray[0].getDay();
return false;
}

//// appointment.cpp file
using std::cin;
using std::cout;

appointment::appointment()
{
day = 0;
cout << "default appt ";
}

appointment::appointment(long lSource, const char cDescription[], int d, int m, int y)
{
source = lSource;
day = d;
month = m;
year = y;
setDescription(cDescription);
}
appointment::appointment(const appointment & aToCopy)
{
source = aToCopy.getSource();
day = aToCopy.getDay();
month = aToCopy.getMonth();
year = aToCopy.getYear();
setDescription(aToCopy.getDescription());
}


void appointment::setDescription(const char * cSource)
{
if (desc != NULL) free (desc);

if (cSource == NULL)
return;

desc = (char *)malloc (strlen (cSource) + 1);
strcpy(desc, cSource);
}

long appointment::getSource(void) const
{
return source;
}

void appointment::setSource(long lSource)
{
source = lSource;
}

void appointment::setMonth(int iMonth)
{
month = iMonth;
}

void appointment::setDay(int iDay)
{
day = iDay;
}

void appointment::setYear(int iYear)
{
year = iYear;
}

int appointment::getMonth(void) const
{
return month;
}

int appointment::getDay(void) const
{
return day;
}

int appointment::getYear(void) const
{
return year;
}
const char * appointment::getDescription(void) const
{
return desc;
}
void appointment::changeDescription(const char * cDescription)
{
setDescription(cDescription);
}

void appointment::copyTo(appointment &p) const
{
p.source = source;
p.day = day;
p.month = month;
p.year = year;
p.setDescription(desc);
}

void appointment::incrementDate(void)
{
int days;

switch (month)
{
case 1: // Jan: 31 Days
case 3: // Mar: 31 Days
case 5: // May: 31 Days
case 7: // Jul: 31 Days
case 10: // Oct: 31 Days
case 12: // Dec: 31 Days
days = 31;
break;

case 4: // Apr: 30
case 6: // Jun: 30
case 8: // Aug: 30
case 9: // Sep: 30
case 11: // Nov: 30
days = 30;
break;

case 2: // Feb: 28/29 Days (Depends on year modulus 4 a modulus 100).
days = !(year % 4) || !(year % 100) ? 29 : 28;
break;
}

day++;

if (day > days)
{
month++;
day = 1;

if (month > 12)
{
month = 1;
year++;
}
}
}

void appointment::printS(ostream &out, int dateFormat) const
{
if (dateFormat == 1)
{
out << month << "/" << day << "/" << year << " ";
}
else if (dateFormat == 2)
{
out << day << "/" << month << "/" << year << " ";
}
else
out << "Unsupported dateFormat parameter specified (should be 1 or 2).";
}

appointment::~appointment()
{
if (desc != NULL)
{
free (desc);
desc = NULL;
}
}

void appointment::keyBoardInput()
{
char temp[1024];

cout << "Please type the description: ";
cin.getline (temp, sizeof(temp) - 1, ' ');
cout << std::endl;

setDescription(temp);
}

}
}