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

Consider the definition of the following class: (1, 2, 3, 5,7) class productType

ID: 3585365 • Letter: C

Question

Consider the definition of the following class: (1, 2, 3, 5,7) class productType public: //Line 1 //Line 2 //Line 3 //Line 4 //Line 5 productType (string, int, double, double) //Line 6 productType ) productType (int, double, double) productType (string, string, string int, double, double) //Line 7 void set (string, string, string, int, //Line8 //Line 9 double, double); void print) const void setQuantitiesInStock (int x); void updateQuantitiesInstock (int x); int getQuantitiesInStock) const; //Line 10 //Line 11 //Line 12 void setPrice (double x); double getPrice ) const; void setDiscount (double d); double getDiscount ) const; //Line 13 //Line 14 //Line 15 //Line 16 private: string productName: string id; string manufacturer; int quantitiesInStock; double price; double discount; //Line 17 //Line 18 //Line 19 //Line 20 //Line 21 //Line 22 //Line 23 //Line 24 Consider the definition of the class productType as given Answer the following questions. (1, 2, 3, 5,7) Write the definition of the function set so that instance variables are set according to the paramaters. Instance variables quantitiesInstock, price, and discount must be nonnegative. Write the definition of the function print to output the values of the instance variables a. b. c. Write the definition of the function setQuantitiesInstock to set the value of the instance variable quantitiesInstock accord- ing to the parameter.

Explanation / Answer

(a)

void productType::setQuantitiesInStock(int x)

{

if(x>0)

this->quantitiesInStock=x;

}

void productType::setPrice(double x)

{

if(x>0)

{

this->price=x;

}

}

void productType::setDiscount(double d)

{

if(d>0)

{

this->discount=d;

}

}

______________________

(b)

void productType::print()const

{

cout<<"Quantities in Stock :"<<this->quantitiesInStock<<endl;

cout<<"Price :"<<this->price<<endl;

cout<<"Discount :"<<this->discount<<endl;

}

______________________

(c)

void productType::setQuantitiesInStock(int x)

{

this->quantitiesInStock=x;

}

________________________Thank You