subject

Consider the class as partially defined here: //class PizzaOrder
class PizzaOrder
{
public:
static const int MAX_TOPPINGS = 20;
private:
// instance members
string toppings[MAX_TOPPINGS];
int numToppings;
// constructor
public PizzaOrder();
// accessor tells # toppings on pizza, i. e., # toppings in array
int getNumToppings() { return numToppings; }
// etc.
}
PizzaOrder::PizzaOrder()
{
numToppings = 0;
}
We want to write an instance method, addTopping() that will take a string parameter, topping, and add it to the toppings[] array at the next available location as determined by the int member numToppings. Assume any string passed in is valid and no other method modifies the toppings[] array or numToppings.
The client would call it like so:
somePizzaOrder. addTopping( "onions" );
Which is a correct definition for addTopping() based on what you see, above?
A. bool PizzaOrder::addTopping( string topping )
{
numToppings++;
if ( numToppings >= MAX_TOPPINGS )
return false;
toppings[numToppings] = topping;
return true;
}
B. void PizzaOrder::addTopping( string topping )
{
toppings[numToppings] = topping;
}
C. bool PizzaOrder::addTopping( string topping )
{
if ( numToppings >= MAX_TOPPINGS || numToppings < 0 )
return false;
toppings[numToppings++] = topping;
return true;
}
D. void PizzaOrder::addTopping( string topping )
{
toppings[numToppings++] = topping;
}
E. bool PizzaOrder::addTopping( string topping )
{
if ( numToppings >= MAX_TOPPINGS )
return false;
toppings[numToppings++] = topping;
return true;
}
F. bool PizzaOrder::addTopping( string topping )
{
if (numToppings > MAX_TOPPINGS)
return false;
toppings[numToppings++] = topping;
return true;
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 02:30
Write a program that takes in 3 inputs [players (int type), expected game time (double type), team (char type)] and calculates actual game time (double) based on the following conditions: if the number of players or the expected game time is less than or equal to zero, it should output wrong input if the number of players is greater than 0 and less than or equal to 6 and if they are on the â€r’ or â€r’ team, their game time will be 10% faster. and if they are on the â€b’ or â€b’ team, their game time will be 15% faster. and if they are on the â€y’ or â€y’ team, their game time will be 20% faster. and if they are on any other team, they will play 0% faster. if the number of players is greater than 6 but less than or equal to 12 and if they are on the â€r’ or â€r’ team, their game time will be 20% faster. and if they are on the â€b’ or â€b’ team, their game time will be 25% faster. and if they are on the â€y’ or â€y’ team their game time will be 30% faster. and if they are on any other team, they will play 0% faster. if the number of players is greater than 12 but less than or equal to 18 and if they are on the â€r’ or â€r’ team, their game time will be 30% faster. and if they are on the â€b’ or â€b’ team, their game time will be 35% faster. and if they are on the â€y’ or â€y’ team, their game time will
Answers: 2
question
Computers and Technology, 22.06.2019 10:30
How can a user open a blank presentation? 1.on the file menu, click new, and then click recent templates 2.on the file menu, click new, and then click blank presentation 3. on the view menu, click templates, and then click recent templates 4. on the view menu, click samples, and then click blank presentation
Answers: 1
question
Computers and Technology, 23.06.2019 09:00
Which best describes the role or restriction enzymes in the analysis of edna a. to break dna into fragments that vary in size so they can be sorted and analyzed b. to amplify small amounts of dna and generate large amounts of dna for analysis c. to purify samples of dna obtained from the environment so they can be analyzed d. to sort different sizes of dna fragments into a banding pattern that can be analyzed
Answers: 1
question
Computers and Technology, 23.06.2019 11:30
The most accurate readings that you can take on an analog vom are when the meter's pointer is at the a. center scale. b. extreme right. c. near right. d. extreme left.
Answers: 1
You know the right answer?
Consider the class as partially defined here: //class PizzaOrder
class PizzaOrder
{
Questions
question
Mathematics, 09.12.2020 21:30
question
Mathematics, 09.12.2020 21:30
question
Arts, 09.12.2020 21:30
question
Computers and Technology, 09.12.2020 21:30
question
Mathematics, 09.12.2020 21:30
question
Mathematics, 09.12.2020 21:30
Questions on the website: 13722360