OU ONLY NEED TO EDIT date.h, dateOFYear.h, and dateOFYear.cpp date.h | date.cpp | dateOfYear.h | dateOfYear.cpp | dateTest.cpp

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

C++
YOU ONLY NEED TO EDIT date.h, dateOFYear.h, and dateOFYear.cpp

date.h | date.cpp | dateOfYear.h | dateOfYear.cpp | dateTest.cpp

You have been provided a Date class. Each date contains day and month parameters, a default and a custom constructor, mutator and accessor functions for the parameters, and input and output functions called within operator >> and <<.

You will be writing a DateOfYear class, which expands on the Date class by adding a year parameter. This will be achieved via inheritance – DateOfYear is the derived class of the Date base class. In DateOfYear, will need to write…

  • The include guards for the class
  • A default constructor that initializes all parameters to 1
  • A custom constructor that takes in a month, day, and year to initialize the parameters
  • Mutator and accessor for the year parameter
  • Redefined versions of inputDate and outputDate that takes into account the new year parameter.

The driver program, dateTest.cpp, is already set for use with both Date and DateOfYear. All you need to do is complete the DateOfYear class and make sure it is compatible with the date class.

HINT: The inputDate and outputDate functions are used within the operator >> and << functions inside of the Date class. Although you are redefining them in dateOfYear, you’ll need to do something to the base class header to make sure everything works correctly.

See the Sample Runs for reference (user input bolded and underlined):

Same Days

Enter month: 9

Enter day: 18

Enter month: 9

Enter day: 18

Enter year: 1995

9/18

2/27

9/18/1995

3/1/1996

d1 is your birthday!

Different Days

Enter month: 9

Enter day: 13

Enter month: 10

Enter day: 27

Enter year: 2017

9/13

2/27

10/27/2017

3/1/1996

These are different days.

date.cpp

//Date Class Implementation
#include "date.h"

// Friend Function of Date
bool equal(const Date& date1, const Date& date2)
{
return (date1.month == date2.month && date1.day == date2.day);
}

Date::Date():month(1), day(1)
{
  
}

Date::Date(int m, int d):month(m), day(d)
{
  
}

void Date::setMonth(int m)
{
   month = m;
}

void Date::setDay(int d)
{
   day = d;
}

double Date::getMonth() const
{
return month;
}

double Date::getDay() const
{
return day;
}

void Date::inputDate(istream& ins)
{
   cout << "Enter month: ";
   ins >> month;
   cout << "Enter day: ";
   ins >> day;
}

void Date::outputDate(ostream& outs) const
{
   outs << month << '/' << day << endl;
}

istream& operator >>(istream& ins, Date& d)
{
   d.inputDate(ins);
}

ostream& operator <<(ostream& outs, const Date& d)
{
   d.outputDate(outs);
}

date.h

// Holds a month and a day to represent a date.
#ifndef DATE_H
#define DATE_H

#include <iostream>
using namespace std;

class Date
{
public:
friend bool equal(const Date& date1, const Date& date2);
//Precondition: date1 and date2 have values.
//Returns true if date1 and date2 represent the same date;
//otherwise, returns false.
Date();
Date(int m, int d);
   void setMonth(int m);
   void setDay(int d);
double getMonth() const;
double getDay() const;
void inputDate(istream& ins);
void outputDate(ostream& outs) const;
   friend istream& operator >>(istream& ins, Date& d);
   // Input Operator >>
   // calls the inputDate function within here to perform input.
   friend ostream& operator <<(ostream& outs, const Date& d);
   // Output Operator <<
   // Calls the outputDate function within here to perform output.

private:
   int month;
   int day;
};

#endif

dateOFYear.cpp

#include <iostream>
using namespace std;
#include "dateOfYear.cpp"

// Implement the member functions!

dateOFYear.h

#include "date.h"
#include <iostream>
using namespace std;

// Include Guards:x

class DateOfYear
{
public:
   // Create Constructors Here

   // Mutators and Accessor Functions Here

   // inputDate and outputDate here, taking into account the new

private:
   // Declare new data members here
};

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Types of trees
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY