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

Consider the definition of the class productType as given in Exercise 8. Answer

ID: 3909268 • Letter: C

Question

Consider the definition of the class productType as given in Exercise 8. Answer the following questions a. 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. b. Write the definition of the function print to output the values of the instance variables. c. Write the definition of the function setQuantitiesInStock to set the value of the instance variable quantitiesInStock according to the parameter d. Write the definition of the function updateQuantitiesInStock to update the value of instance variable quantitiesInStock by adding the value of the parameter e. Write the definition of the function getQuantitiesInStock to return the value of instance variable qruantitiesInstock. f. Write the definition of the function setPrice to set the value of the instance variable price according to the parameter. g. Write the definition of the function getPrice to return the value of the instance variable price. h. Write the definition of the function setDiscount to set the value of the instance variable discount according to the parameter i. Write the definition of the function getDiscount to return the value of the instance variable discount.

Explanation / Answer

Hi, please go threw the code i wretten bellow.it is according to your assignment.

class productType

{

unsigned int quantitiesInStock;

unsigned int price;

unsigned int discount;

//a

void setFun(unsigned int quantitiesInStock_a, unsigned int price_a, unsigned int discount_a)

{

quantitiesInStock = quantitiesInStock_a;

price = price_a;

discount = discount_a;

}

//b

void printFun(productType & obj)

{

cout << "quantitiesInStock - " << quantitiesInStock << "price - " << price << "discount - " << discount << endl;

}

//c

void setQuantitiesInStock(unsigned int quantitiesInStock_a)

{

quantitiesInStock = quantitiesInStock_a;

}

//d

void updateQuantitiesInStock(unsigned int quantitiesInStock_a)

{

quantitiesInStock += quantitiesInStock_a;

}

//e

unsigned int getQuantitiesInStock(void)

{

return quantitiesInStock;

}

//f

void setPrice(unsigned int price_a)

{

price = price_a;

}

//g

unsigned int getPrice(void)

{

return price;

}

//h

void setDiscount(unsigned int discount_a)

{

discount = discount_a;

}

//i

unsigned int getDiscount(void)

{

return discount;

}

};