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

Define a class called Pizza that has member variables to track the type of pizza

ID: 3671018 • Letter: D

Question

Define a class called Pizza that has member variables to track the type of pizza (either deep dish, hand tossed or pan) along with the size (either small, medium or large) and the number of pepperoni or cheese toppings. You can use constants to represent the type and size. Include mutate and accessory functions for your class. Create a void function, outputDescription(), that outputs a textual description of the pizza object. Also include a function, computePrice(), that computes the cost of the-pizza and returns is as a double according to the following rules: Small pizza $10 + $2 per topping Medium pizza $14 + $2 per topping Large pizza = $17 + $2 per toeing. Write a suitable test program that creates and outputs a description and price-of various pizza objects.

Explanation / Answer

#include <iostream>
using namespace std ;

const int PAN_PIZZA= 3 ;
const int DEEP_DISH= 1 ;
const int HAND_TOSSED= 2 ;
const int L_PIZZA= 3 ;
const int M_PIZZA= 2 ;
const int S_PIZZA= 1 ;

class Pizza
{
private:

int size ;
int type ;
bool pepperoni_Toppings ;
bool cheeze_Toppings ;

public:
Pizza() ;
int getValume() ;
int getKind() ;
bool getPeperoni() ;
bool getCheese() ;
void setValume( int s ) ;
void setKind( int t ) ;
void setPeperoni( bool option ) ;
void setCheeze( bool option ) ;

double computePrice( ) ;
void outputDescription( ) ;
} ;

Pizza::Pizza()
{
size= S_PIZZA ;
type= DEEP_DISH ;
cheeze_Toppings= pepperoni_Toppings= false ;
}

int Pizza::getValume()
{
return size ;
}

int Pizza::getKind()
{
return type ;
}

bool Pizza::getPeperoni()
{
return pepperoni_Toppings ;
}

bool Pizza::getCheese()
{
return cheeze_Toppings ;
}

void Pizza::setValume( int s )
{
size= s ;
}

void Pizza::setKind( int t )
{
type= t ;
}

void Pizza::setPeperoni( bool option )
{
pepperoni_Toppings= option ;
}

void Pizza::setCheeze( bool option )
{
cheeze_Toppings= option ;
}

double Pizza::computePrice()
{
double price =0.0 ;
switch( size )
{
case S_PIZZA:
price +=10 ;break ;
case M_PIZZA:
price +=14 ;break ;
case L_PIZZA:
price +=17 ;break ;
}

if( cheeze_Toppings )
price +=2.0 ;
if( pepperoni_Toppings )
price +=2.0 ;

return price ;
}

void Pizza::outputDescription()
{
switch( size )
{
case S_PIZZA:
cout << " S_PIZZA " ;break ;
case M_PIZZA:
cout << " M_PIZZA " ;break ;
case L_PIZZA:
cout << " L_PIZZA " ;break ;
default:
cout << " Unknown sized " ;
}

switch( type )
{
case DEEP_DISH:
cout << " deep dish" ;break ;
case HAND_TOSSED :
cout << " hand tossed" ;break ;
case PAN_PIZZA:
cout << " PAN_PIZZA" ;break ;
default:
cout << " unknown kind" ;
}

cout << " MY_PIZZAAA hh !! " ;
}

int main()
{
int type= 0 ,size= 0 ;
char pKind, pValume, pizzaToppings, temp ;

cout << " What valume pizza would u like ( S / M / L ) : " ;
cin >> pValume ;
cin.clear() ;

switch ( pValume )
{
case 'L': case 'l':
size= L_PIZZA ;break ;
case 'M': case 'm':
size= M_PIZZA ;break ;
case 'S': case 's':
size= S_PIZZA ;break ;
}

cout << " What kind pizza would u like ( ( D ) Deepdish / ( H ) Hand_tossed / ( P ) Pan ) : " ;
cin >> pKind ;
cin.clear() ;

switch ( pKind )
{
case 'P': case 'p':
type= PAN_PIZZA; break ;
case 'D': case 'd':
type= DEEP_DISH ;break ;
case 'H': case 'h':
type= HAND_TOSSED ;break ;
}

Pizza pizzaObj ;
pizzaObj.setKind( type ) ;
pizzaObj.setValume( size ) ;

cout << " Would u like cheeze toppings ( YES / NO ) ? " ;
cin >> pizzaToppings ;
cin.clear() ;

if( pizzaToppings =='Y' ||pizzaToppings =='y' )
pizzaObj.setcheeze( true ) ;

cout << " Would u like pepperoni toppings ( YES / NO ) ? " ;
cin >> pizzaToppings ;
cin.clear() ;

if( pizzaToppings =='Y' ||pizzaToppings =='y' )
pizzaObj.setPeperoni( true ) ;

cout << endl << " Ur order : " ;
pizzaObj.outputDescription() ;
cout << endl ;

cout << " Price : $ " << pizzaObj.computePrice() << endl ;

system( " pause " ) ;

return 0 ;
}

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