finish the pizza class declaration by creating mutator and accessor functions fo
ID: 3780056 • Letter: F
Question
finish the pizza class declaration by creating mutator and accessor functions for the type of pizza, called pizzaType, and the number of slices, called numSlices.Then create two Constructors: the default and the overloaded Constructor. The default Constructor will initialize the type of pizza to "cheese" and the number of slices 0. the overloaded Constructor will take as an argument the type of pizza and the number of slices.
class Pizza {
private:
//FINISH ME
public:
//FINISH ME with mutator and assessor declaration
//FINISH ME with Constructor declaration
};
//FINISH ME with default Constructor
//FINISH ME with overloaded Constructor
Explanation / Answer
class Pizza
{
private:
string pizzaType;
int numSlices;
public:
void setPizzaType(string type)
{
pizzaType=type;
}
void setNumSlices(int n)
{
numSlices=n;
}
int getNumSlices()
{
return numSlices;
}
string getPizzaType()
{
return pizzaType;
}
Pizza();
Pizza(string type,int n);
};
Pizza::Pizza()
{
pizzaType="cheese";
numSlices=0;
}
Pizza::Pizza(string type,int n)
{
pizzaType=type;
numSlices=n;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.