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

The class Holiday represents a celebrated day. As you\'ll from its class diagram

ID: 3770349 • Letter: T

Question

The class Holiday represents a celebrated day. As you'll from its class diagram, it is a concrete (instantiatable) class which might represent a Labor Day or Veteran's Day. The class MealOrientedHoliday is a much more specific kind of Holiday that identifies a holiday centered around a meal. Following the diagrams show below, create the classes Holiday and MealOrientedHoliday. A sample driver has been provided to guide your efforts. IN ORDER TO RECEIVE FULL CREDIT, YOUR SUBCLASS MUST CALL ITS PARENT CONSTRUCTOR AS WELL AS REUSE ITS PARENT'S PROTECTED MEMBERS.

Explanation / Answer

#include <iostream>
#include <string>
using namespace std;

class Holiday {

protected:
   string name;
   int month;
   int day;
   int year;

public:
   Holiday();
   Holiday(string hname, int hmonth, int hday, int hyear) {
       name = hname;
       month = hmonth;
       day = hday;
       year = hyear;
   }

   int getMonth() {
       return month;
   }

   int getDay() {
       return day;
   }

   int getYear() {
       return year;
   }
};


class MealOrientedHoliday : public Holiday {

protected:
   string myMeal;
public:
   MealOrientedHoliday();
   MealOrientedHoliday( string name,
                         int month,
                         int day,
                         int year,
                         string meal ) : Holiday(name, month, day, year) {
       myMeal = meal;
   }

   std::string getMeal( ) const;
};


int main()
{
   Holiday veteransDay( "Veteran's Day", 11, 11, 2015 );
   MealOrientedHoliday turkeyDay( "Thanksgiving", 11, 26, 2015, "dinner" );

   cout << "this day is Veteran's Day: " << veteransDay.getMonth( ) << "/" << veteransDay.getDay( ) << "/" << veteransDay.getYear( ) << endl;
   cout << "this day is Thanksgiving: " << turkeyDay.getMonth( ) << "/" << turkeyDay.getDay( ) << "/" << turkeyDay.getYear( ) << endl;
   return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote