Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

n 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

n 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; };

// 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;

}

In DateType.cpp file, type these lines:

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.

https://www.onlinegdb.com/online_c++_compiler

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Distributed Relational Database Architecture Connectivity Guide

Authors: Teresa Hopper

4th Edition

0133983064, 978-0133983067

More Books

Students also viewed these Databases questions

Question

6. Explain the strengths of a dialectical approach.

Answered: 1 week ago

Question

2. Discuss the types of messages that are communicated nonverbally.

Answered: 1 week ago