Complete the following definitions of the Recipe and Recipe Book classes: • The Recipe class has private data members: cupsFlour and tbspButter. The RecipeBook class has private data members: recipes, recipes Capacity, and recipesSize. recipes is a dynamically allocated array of Recipe objects. Then, implement the following five member functions of the RecipeBook class: • The class constructor: Initializes data members. • IncreaseCapacity(): Increases the size of the dynamically allocated array by the specified value and updates the member values accordingly. • AddRecipe(): Assigns an unused element with the specified values for cups Flour and tbspButter, and updates recipesSize. GetRecipeAt(): Returns the Recipe at the specified index. • • GetSize(): Returns recipesSize. How to use this tool Unused return recipesSize; int recipesCapacity; Recipe* recipes; int tbspButter; Recipe* newRecipes; int i; recipesCapacity += increaseval; newRecipes = new Recipe [recipesCapacity]; for (i = 0; i < recipesSize; ++i) { newRecipes[i] = recipes[i]; } main.cpp #include using namespace std; class Recipe { public: }; Recipe (double flourval = 0, int butterval = 0); void SetCups Flour (double cups Flour); void SetTbspButter (int tbspButter); double GetCups Flour(); int GetTbspButter(); private: Recipe::Recipe (double flourval, int butterval) { cups Flour = flourval; tbspButter = butterval; delete[] recipes; recipes = newRecipes; int recipesSize; return recipes [index]; double cupsFlour; recipes = nullptr; recipesCapacity = 0; recipesSize = 0; recipes[recipesSize].SetCups Flour (cups Flour); recipes [recipesSize].setTbspButter (tbspButter); recipesSize += 1; } void Recipe::SetCups Flour (double recipeCups Flour) { cupsFlour = recipeCups Flour; } void Recipe::SetTbspButter(int recipeTbspButter) { tbspButter = recipeTbspButter; } double Recipe::GetCups Flour () { return cupsFlour; } int Recipe::GetTbspButter() { return tbspButter; } class Recipe Book { public: RecipeDook(); void IncreaseCapacity (int increaseval); void AddRecipe(double cups Flour, int tbspButter); Recipe GetRecipeAt(int index); int GetSize(); private: }; Load default template...

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter9: Using Classes And Objects
Section: Chapter Questions
Problem 2CP
icon
Related questions
Question

Help with this C++ problem.
Show exact steps of the placement.

 
Complete the following definitions of the Recipe and Recipe Book classes:
• The Recipe class has private data members: cupsFlour and tbspButter.
The RecipeBook class has private data members: recipes, recipes Capacity, and recipesSize. recipes is a dynamically allocated array of Recipe objects.
Then, implement the following five member functions of the RecipeBook class:
• The class constructor: Initializes data members.
• IncreaseCapacity(): Increases the size of the dynamically allocated array by the specified value and updates the member values accordingly.
• AddRecipe(): Assigns an unused element with the specified values for cups Flour and tbspButter, and updates recipesSize.
GetRecipeAt(): Returns the Recipe at the specified index.
•
• GetSize(): Returns recipesSize.
How to use this tool
Unused
return recipesSize;
int recipesCapacity;
Recipe* recipes;
int tbspButter;
Recipe* newRecipes;
int i;
recipesCapacity += increaseval;
newRecipes = new Recipe [recipesCapacity];
for (i = 0; i < recipesSize; ++i) {
newRecipes[i] = recipes[i];
}
main.cpp
#include <iostream>
using namespace std;
class Recipe {
public:
};
Recipe (double flourval = 0, int butterval = 0);
void SetCups Flour (double cups Flour);
void SetTbspButter (int tbspButter);
double GetCups Flour();
int GetTbspButter();
private:
Recipe::Recipe (double flourval, int butterval) {
cups Flour = flourval;
tbspButter = butterval;
delete[] recipes;
recipes = newRecipes;
int recipesSize;
return recipes [index];
double cupsFlour;
recipes = nullptr;
recipesCapacity = 0;
recipesSize = 0;
recipes[recipesSize].SetCups Flour (cups Flour);
recipes [recipesSize].setTbspButter (tbspButter);
recipesSize += 1;
}
void Recipe::SetCups Flour (double recipeCups Flour) {
cupsFlour = recipeCups Flour;
}
void Recipe::SetTbspButter(int recipeTbspButter) {
tbspButter = recipeTbspButter;
}
double Recipe::GetCups Flour () {
return cupsFlour;
}
int Recipe::GetTbspButter() {
return tbspButter;
}
class Recipe Book {
public:
RecipeDook();
void IncreaseCapacity (int increaseval);
void AddRecipe(double cups Flour, int tbspButter);
Recipe GetRecipeAt(int index);
int GetSize();
private:
};
Load default template...
Transcribed Image Text:Complete the following definitions of the Recipe and Recipe Book classes: • The Recipe class has private data members: cupsFlour and tbspButter. The RecipeBook class has private data members: recipes, recipes Capacity, and recipesSize. recipes is a dynamically allocated array of Recipe objects. Then, implement the following five member functions of the RecipeBook class: • The class constructor: Initializes data members. • IncreaseCapacity(): Increases the size of the dynamically allocated array by the specified value and updates the member values accordingly. • AddRecipe(): Assigns an unused element with the specified values for cups Flour and tbspButter, and updates recipesSize. GetRecipeAt(): Returns the Recipe at the specified index. • • GetSize(): Returns recipesSize. How to use this tool Unused return recipesSize; int recipesCapacity; Recipe* recipes; int tbspButter; Recipe* newRecipes; int i; recipesCapacity += increaseval; newRecipes = new Recipe [recipesCapacity]; for (i = 0; i < recipesSize; ++i) { newRecipes[i] = recipes[i]; } main.cpp #include <iostream> using namespace std; class Recipe { public: }; Recipe (double flourval = 0, int butterval = 0); void SetCups Flour (double cups Flour); void SetTbspButter (int tbspButter); double GetCups Flour(); int GetTbspButter(); private: Recipe::Recipe (double flourval, int butterval) { cups Flour = flourval; tbspButter = butterval; delete[] recipes; recipes = newRecipes; int recipesSize; return recipes [index]; double cupsFlour; recipes = nullptr; recipesCapacity = 0; recipesSize = 0; recipes[recipesSize].SetCups Flour (cups Flour); recipes [recipesSize].setTbspButter (tbspButter); recipesSize += 1; } void Recipe::SetCups Flour (double recipeCups Flour) { cupsFlour = recipeCups Flour; } void Recipe::SetTbspButter(int recipeTbspButter) { tbspButter = recipeTbspButter; } double Recipe::GetCups Flour () { return cupsFlour; } int Recipe::GetTbspButter() { return tbspButter; } class Recipe Book { public: RecipeDook(); void IncreaseCapacity (int increaseval); void AddRecipe(double cups Flour, int tbspButter); Recipe GetRecipeAt(int index); int GetSize(); private: }; Load default template...
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning