Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

IN C++, Consider the following declarations: class bagType { public: void set( s

ID: 3675610 • Letter: I

Question

IN C++,

Consider the following declarations:

class bagType

{

public:

       void set( string, double, double, double, double);

       void print() const;

       string getStyle() const;

       double getPrice() const;

       void get( double, double, double, double);

       bagType();

       bagType(string, double, double, double, double);

private:

       string style;

       double l;

       double w;

       double h;

       double price;

};

bagType newBag; // variable declaration

a. How many members does class bagType have?

b. How many private members does class bagType have?

c. How many constructors does class bagType have?

d. How many constant functions does class bagType have?

e. Which constructor is used to initialize the object newBag?

f. Write the definition of the member function set so that private members are set according to the parameters.

g. Write the definition of the member function print that prints the values of the data members.

h. Write the definition of the default constructor of the class bagType so that the private member variables are initialized to "", 0.0, 0.0, 0.0, 0.0, respectively.

i. Write a C++ statement that prints the value of the object newBag.

j. Write a C++ statement that declares the object tempBag of type bagType, and initializes the member variables of tempBag to "backPack", 15, 8, 20, and 49.99, respectively.

(2) About designing and implementing a C++ class.

Design and Implement a class called personType the following properties:

a. The class personType has four member variables: name (string), age (int), weight (double), height (double)

b. The class personType has the following member functions. (Make each accessor function constant. Can you figure out which functions are accessor functions?)

print— outputs the data stored in the member variables with the appropriate titles

setName— function to set the name

setAge— function to set the age

setWeight— function to set the weight

setHeight— function to set the height

getName— value- returning function to return the name

getAge— value- returning function to return the age

getWeight— value- returning function to return the weight

getHeight— value- returning function to return the height

constructor— with default parameters: The default value of name is the empty string "", and the default values of age, weight, and height are 0.

(3) About designing and implementing a C++ class.

Design and implement a class dayType that implements the day of the week in a program. The class dayType should store the day, such as Sun for Sunday. The program should be able to perform the following operations on an object of type dayType:

a. Set the day.

b. Print the day.

c. Return the day.

d. Return the next day.

e. Return the previous day.

f. Calculate and return the day by adding certain days to the current day. For example, if the current day is Monday and we add 4 days, the day to be returned is Friday. Similarly, if today is Tuesday and we add 13 days, the day to be returned is Monday.

g. Add the appropriate constructors.

Save your program as lab5-3-yourName.cpp.

(4) About utilizing an existing (a third party) C++ class in a program.

Some other programmer created a C++ class called die that represents a real life die. You can find the source code (the .h and .cpp files) that implements class die in Lab Filesfolder.

Write a program that will use (include) class die. In your program will declare an array named rolls, of 100 components of type die. Your program should roll each die of the array and find out and then output the highest number rolled.

class bagType

{

public:

       void set( string, double, double, double, double);

       void print() const;

       string getStyle() const;

       double getPrice() const;

       void get( double, double, double, double);

       bagType();

       bagType(string, double, double, double, double);

private:

       string style;

       double l;

       double w;

       double h;

       double price;

};

bagType newBag; // variable declaration

Explanation / Answer

As per the rules of the chegg , You have to post each question separately.

Here is the answer for your fist question.

a. How many members does class bagType have?
Answer: member variable are called as members and they are 5 in number.They are
string style;
double l;
double w;
double h;
double price;
member functions are 5 in number
void set( string, double, double, double, double);
void print() const;
string getStyle() const;
double getPrice() const;
void get( double, double, double, double);
The follwoing are the two constructors.
bagType();
bagType(string, double, double, double, double);

b. How many private members does class bagType have?
Answer: There are 5 .
string style;
double l;
double w;
double h;
double price;

c. How many constructors does class bagType have?
Answer: 2
The follwoing are the two constructors.
bagType();
bagType(string, double, double, double, double);

d. How many constant functions does class bagType have?
Answer:3
void print() const;
string getStyle() const;
double getPrice() const;

e. Which constructor is used to initialize the object newBag?
Answer:
bagType(string, double, double, double, double);
Because using this constructor you can pass parameters to it so that it can receive and initialize it with those values.
f. Write the definition of the member function set so that private members are set according to the parameters.
Answer:
void bagType::set( string s, double i, double j, double k, double l)
{
strcpy(style,s);
l = i;
w =j;
h = k;
price = l;
}
  
g. Write the definition of the member function print that prints the values of the data members.
Answer:
void bagType::print()
{
cout <<style<< endl;
cout <<l << endl;
cout <<w << endl;
cout << h << endl;
cout <<price << endl;
}

h. Write the definition of the default constructor of the class bagType so that the private member variables are initialized to "", 0.0, 0.0, 0.0, 0.0, respectively.
Answer:
bagType::bagType()
{
strcpy(style,"");
l = 0.0;
w =0.0;
h = 0.0;
price = 0.0;
}

i. Write a C++ statement that prints the value of the object newBag.
Answer:
newBag.print();
j. Write a C++ statement that declares the object tempBag of type bagType, and initializes the member variables of tempBag to "backPack", 15, 8, 20, and 49.99, respectively.
bagType tempBag("backPack", 15, 8, 20, 49.99);