Question: In this programming assignment, you need to create 3 files. 1. DateType.h 2. DateType.cpp 3. A test driver for testing the class defined in the
In this programming assignment, you need to create 3 files. 1. DateType.h 2. DateType.cpp 3. A test driver for testing the class defined in the other 2 files. You can name your file in the way you like. Remember it must be a .cpp file. In DateType.h file, type these lines: // To declare a class for the Date ADT // This is the header file DateType.h class DateType { public: void Initialize(int newMonth, int newDay, int newYear); int GetYear() const; int GetMonth() const; int GetDay() const; private: int year; int month; int day; }; In DateType.cpp file, type these lines: // Class implementation // DateType.cpp #include "DateType.h" void DateType::Initialize(int newMonth, int newDay, int newYear) { year = newYear; month = newMonth; day = newDay; } int DateType::GetMonth() const { return month; } int DateType::GetDay() const { return day; } int DateType::GetYear() const { return year; } In you test driver, type in these lines: // test driver // I give the file name: testDriver.cpp // To compile, type c++ DataType.cpp testDriver.cpp, this will generate an a.out executable. // Or, type c++ Type.cpp testDriver.cpp o testdriver, this will generate an executable named testdriver. #include "DateType.h" #include using namespace std; int main() { DateType today; DateType anotherDay; today.Initialize(9, 24, 2003); anotherDay.Initialize(9, 25, 2003); cout << "Today is " << today.GetMonth() << "/" << today.GetDay() << "/" << today.GetYear() << endl; cout << "Anotherday is " << anotherDay.GetMonth() << "/" << anotherDay.GetDay() << "/" << anotherDay.GetYear() << endl; return 0; } Once you have the 3 files ready, you can compile them. The compile command is in the comments of the test driver. After the compilation, you run the program, and see what output you get. Now, modify the code to initialize 2 different dates, compile and run it, and see what the output is. Submission: submit one PDF file which includes YOUR modified c++ program and output of the program.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
