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...

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education