Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in C++ Please In the class definition, initialize the data members, string title, integer year, and integer numWords, with the default values Incomplete, -1, and

in C++ Please

In the class definition, initialize the data members, string title, integer year, and integer numWords, with the default values "Incomplete", -1, and -1, respectively.

Ex: If the input is Daisy 2003 26500, then the output is:

Title: Incomplete, Year: -1, Number of words: -1 Title: Daisy, Year: 2003, Number of words: 26500

Note: The class's print function is called first after the default constructor, then again after the inputs are passed to the setters.

#include #include using namespace std;

class Play { public: void SetTitle(string playTitle); void SetYear(int playYear); void SetNumWords(int playNumWords); void Print();

private:

/* Your code goes here */

};

void Play::SetTitle(string playTitle) { title = playTitle; }

void Play::SetYear(int playYear) { year = playYear; }

void Play::SetNumWords(int playNumWords) { numWords = playNumWords; }

void Play::Print() { cout << "Title: " << title << ", Year: " << year << ", Number of words: " << numWords << endl; }

int main() { string newTitle; int newYear; int newNumWords; Play favoritePlay;

favoritePlay.Print();

cin >> newTitle; cin >> newYear; cin >> newNumWords;

favoritePlay.SetTitle(newTitle); favoritePlay.SetYear(newYear); favoritePlay.SetNumWords(newNumWords);

favoritePlay.Print();

return 0; }

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

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions

Question

What do you think it means to be healthy?

Answered: 1 week ago