c++ ------ Turn in a written report that contains your name on page one, and sta
ID: 3710487 • Letter: C
Question
c++ ------
Turn in a written report that contains your name on page one, and starting on page 2 all file you write-header files and source files-plus output file and a snippet of your output screen. 1. Use separate source files and header files to create a dlass o represent desks a. A desk object has attributes of color (string) and number of drawers (integer) b. Member functions (methods) are: i default constructor with def ault parameter values of "Steel Blue" and 4, and tha displays TnltConstructor calledin.Use constructor initilizer it format Tnltconstructor called jn.Use constructo i. individual get methods for each attribute that are written as in-line function i. a get method (NOT in-line) that uses pass-by-reference for both parameters and has return-type void v. one set method that sets both attrbutes (NOT in-line V. PrintMe method that returns string "Tm a ccolor desk with co drawers.", replacing colorn and co with the appropriate attribute values Destructor that displays AnltDestructor called n 2 Write a complete program that uses the desk dass a. Declare a vector of 5 objects of desk dass b. Declare a single desk object and initialize it at dedaration to have color Siver cCall the PrintMe method of the single object and display to the screen e. Call a void function that has the vector of 5 desks as one parameter That function should Ask the user for S colors and 5 numbers and assign them to each desk in the vector. The numbers must be verified as non-negative or else get another number For the 2d desk, if the color's name is 4 or more characters long.change the 3 character of the name to L. Determine which deski's) has the most drawers, Then, display on the screen "Most drawerso one line, followed by PrintMe information for desks) with that many drawers on the nex line(s)Explanation / Answer
Solution:
Note: The first question is done as per Chegg guidelines, please repost others. code:
#include<iostream>
#include<string.h>
using namespace std;
class Desk
{
public:
string Color;
int drawers;
Desk()
{
Color = "Steel Blue";
drawers = 4;
cout<<" Constructor Called ";
}
string get_Color()
{
return Color;
}
int get_drawers()
{
return drawers;
}
void set(string c, int d)
{
Color = c;
drawers = d;
}
void Printme()
{
cout<<"I'm a "<<Color<<" desk with "<<drawers<<" drawers";
}
~Desk()
{
cout<<" Destructor called ";
}
};
int main()
{
Desk d1;
d1.set("Green", 7);
cout<<d1.get_Color()<<" ";
cout<<d1.get_drawers()<<" ";
d1.Printme();
return 0;
}
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.