Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A few days ago, you all sent me an answer to the below question. The professor tried clarifying some things today that is shown in

A few days ago, you all sent me an answer to the below question. The professor tried clarifying some things today that is shown in some "red ink" below; can you all fix this? Also, I think that I just sent this question to you during the past hour or so.

In Chapter 10, the class clockType was designed to implement the time of day in a program. Certain applications, in addition to hours, minutes, and seconds, might require you to store the time zone. Derive the class extClockType from the class clockType by adding a member variable to store the time zone called timeZone. Add the necessary member functions and constructors to make the class functional. Also, write the definitions of the member functions and the constructors. Finally, write a test program to test your class.

Here is how I would setup the main program for 11-1:

int main()

{

char *str;

int strLen;

int len;

char ch;

int i;

cout << "Enter the size of the string: ";

cin >> strLen;

cout << endl;

cin.get(ch);

str = new char[strLen + 1];

cout << "Enter a string of length at most "

<< strLen << ": ";

cin.get(str, strLen + 1);

cout << endl;

cout << "String in upper case letters is:" << endl;

len = strlen(str);

for (i = 0; i < len; i++)

cout << static_cast(toupper(str[i]));

cout << endl;

return 0;

}

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

For Assignment 11-1. Below is what I gave everyone for main and extClockType.h. Both of these codes need to be put in main() and extClockType.h.

You are needing to write the code for extClockTypeImp.cpp and then put this in extClockTypeImp.cpp

// main() code below. This code will need to be put in main.

//Program that uses the class extClockType

#include

#include "extClockType.h"

using namespace std;

int main()

{

extClockType time1(5, 10, 34, "CST");

extClockType time2;

cout << "Time 1: ";

time1.printTime();

cout << endl;

time2.setTime(12, 45, 59, "PST");

cout << "Time 2: ";

time2.printTime();

cout << endl;

time2.incrementSeconds();

cout << "After incrementing time2 by one second, Time 2: ";

time2.printTime();

cout << endl;

return 0;

}//end main

Code for extClockType.h

#ifndef H_ExtClockType

#define H_ExtClockType

#include

#include "clockType.h"

using namespace std;

class extClockType: public clockType

{

public:

void setTime(int hours, int minutes, int seconds, string tZone);

void printTime();

extClockType(int = 0, int = 0, int = 0, string = "EST");

private:

string timeZone;

};

#endif

The code that you need to write and put in extClockTypeimp.cpp should look something like below

#include

#include

#include "extClockType.h"

using namespace std;

void extClockType::setTime(int hours, int minutes,

int seconds, string tZone)

{

clockType::setTime(hours, minutes, seconds);

timeZone = tZone;

}

void extClockType::printTime()

{

clockType::printTime();

cout << " " << timeZone;

}

extClockType::extClockType(int hours, int minutes,

int seconds, string tZone)

:clockType(hours, minutes, seconds)

{

timeZone = tZone;

}

I hope this helps.

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

More Books

Students also viewed these Databases questions

Question

What are some crimes sometimes related to identity theft?

Answered: 1 week ago