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

Suppose you have a class called Product that has the following instance variable

ID: 3711815 • Letter: S

Question

Suppose you have a class called Product that has the following instance variables defined:

private String prodID;
private String prodName;
private double prodPrice;

--The Product class has getters and setters defined for all the instance variables.
--Suppose there is a sub-class called Book that extends the Product class. In this class there is an instance variable called ISBN, of type String. This instance variable has a getter and a setter.

Write a setter method for the ISBN instance variable for the Book class , which will do two things: 1) set the ISBN instance variable and 2) set the ProdID of the Book object to be the same as that of its ISBN. Just write the setter method code, no need to submit the whole class.

Explanation / Answer

void setter()

{

string ISBN; //variable declaration

cout<<"Enter the ISBN number"<<endl;

cin>>ISBN; //accepting the value from the user

Product.prodID=ISBN; //storing ISBN to the prodID valriable

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote