Goal 1: Update the Fractions Class ADD an implementation that takes an integer as a parameter. The functionality remains the same: Instead of multiplying/dividing the current object with another Fraction, it multiplies/divides with an integer. For example; a fraction 2/3 when multiplied by 4 becomes 8/3. Similarly, a fraction 2/3 when divided by 4 becomes 1/6. Goal 2: Update the Recipe Class Add a private member variable of type int to denote the serving size and initialize it to 1. Update the overloaded extraction operator (<<) to include the serving size. New Member functions to the Recipe Class: 1. Add four member functions get the value of each of the member variable of the Recipe class: getRecipeName(), getIngredientNames(), getIngredientQuantities(), getServingSize() They return the value of the respective member variables. 2. Add and implement a member function that scales the current recipe to a new serving size. The signature of this function is: void scaleRecipe(int newServingSize); 3. Test your code by uncommenting the main.cpp until the line Recipe r4("recipeDumplings.txt"); to get the output below: Following Recipe has 4 ingredients--- Peanut Sauce Recipe for 1 ---Sweet Chilli Sauce (3/4)Peanut Butter (4/3)Soy Sauce (1/2)Hoisin Sauce (1/3)Scale Recipe to 3 servings--- Peanut Sauce Recipe for 3 ---Sweet Chilli Sauce (9/4)Peanut Butter (4)Soy Sauce (3/2)Hoisin Sauce (1)Scale Recipe to 2 servings--- Peanut Sauce Recipe for 2 ---Sweet Chilli Sauce (3/2)Peanut Butter (8/3)Soy Sauce (1)Hoisin Sauce (2/3) 4. Next write a constructor to load them from a file. The signature of this constructor would be: Recipe(string filename); //loads the name, ingredients, and quantity of each recipe from a file Your code should be able to handle a quantity that is Fractional or whole. Uncommenting the next two lines and getting the following output: --- Dumplings Recipe for 1 ---All Purpose Flour (7/2)Sesame Oil (3)Cabbage (3/2)Garlic Chives (1)Soy Sauce (3/2)Minced Ginger (1/3) 5. The last method we will write for the recipe class is to combine current recipe with another.  Recipe combineWith(Recipe& other) const; Below is the output if the next four lines from main.cpp are uncommented: Combining Peanut Sauce with Dumplings--- Peanut Sauce with Dumplings Recipe for 1 ---Sweet Chilli Sauce (3/4)Peanut Butter (4/3)Soy Sauce (2)Hoisin Sauce (1/3)All Purpose Flour (7/2)Sesame Oil (3)Cabbage (3/2)Garlic Chives (1)Minced Ginger (1/3)--- Combined recipe has 9 ingredients --- 6. The last step is to write client code. Combine the Macroni and Lasagna recipes. Then, combine this new recipe created with Four Cheese. Lastly, scale the final recipe for 10 servings! Show off your recipe by printing it. The desired output: --- Macroni with Lasagna with Four Cheese Recipe for 10 ---Macroni (55/2)Water (105/2)Salt (100/3)Cheddar Cheese (55)Bowtie Pasta (40)Swiss Cheese (40/3)Marinara (35)Spinach (15/2)Crushed Red Pepper (5/2)Mozzarella Cheese (20)Provolone (15/2)

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

Goal 1: Update the Fractions Class

ADD an implementation that takes an integer as a parameter. The functionality remains the same: Instead of multiplying/dividing the current object with another Fraction, it multiplies/divides with an integer. For example; a fraction 2/3 when multiplied by 4 becomes 8/3. Similarly, a fraction 2/3 when divided by 4 becomes 1/6.

Goal 2: Update the Recipe Class

Add a private member variable of type int to denote the serving size and initialize it to 1. Update the overloaded extraction operator (<<) to include the serving size.

New Member functions to the Recipe Class:

1. Add four member functions get the value of each of the member variable of the Recipe class:

getRecipeName(), getIngredientNames(), getIngredientQuantities(), getServingSize()

They return the value of the respective member variables.

2. Add and implement a member function that scales the current recipe to a new serving size. The signature of this function is:

void scaleRecipe(int newServingSize);

3. Test your code by uncommenting the main.cpp until the line

Recipe r4("recipeDumplings.txt");

to get the output below:

Following Recipe has 4 ingredients
--- Peanut Sauce Recipe for 1 ---
Sweet Chilli Sauce (3/4)
Peanut Butter (4/3)
Soy Sauce (1/2)
Hoisin Sauce (1/3)

Scale Recipe to 3 servings
--- Peanut Sauce Recipe for 3 ---
Sweet Chilli Sauce (9/4)
Peanut Butter (4)
Soy Sauce (3/2)
Hoisin Sauce (1)

Scale Recipe to 2 servings
--- Peanut Sauce Recipe for 2 ---
Sweet Chilli Sauce (3/2)
Peanut Butter (8/3)
Soy Sauce (1)
Hoisin Sauce (2/3)

4. Next write a constructor to load them from a file. The signature of this constructor would be:

Recipe(string filename); //loads the name, ingredients, and quantity of each recipe from a file

Your code should be able to handle a quantity that is Fractional or whole.

Uncommenting the next two lines and getting the following output:

--- Dumplings Recipe for 1 ---
All Purpose Flour (7/2)
Sesame Oil (3)
Cabbage (3/2)
Garlic Chives (1)
Soy Sauce (3/2)
Minced Ginger (1/3)

5. The last method we will write for the recipe class is to combine current recipe with another. 

Recipe combineWith(Recipe& other) const;

Below is the output if the next four lines from main.cpp are uncommented:

Combining Peanut Sauce with Dumplings
--- Peanut Sauce with Dumplings Recipe for 1 ---
Sweet Chilli Sauce (3/4)
Peanut Butter (4/3)
Soy Sauce (2)
Hoisin Sauce (1/3)
All Purpose Flour (7/2)
Sesame Oil (3)
Cabbage (3/2)
Garlic Chives (1)
Minced Ginger (1/3)
--- Combined recipe has 9 ingredients ---

6. The last step is to write client code. Combine the Macroni and Lasagna recipes. Then, combine this new recipe created with Four Cheese. Lastly, scale the final recipe for 10 servings! Show off your recipe by printing it.

The desired output:

--- Macroni with Lasagna with Four Cheese Recipe for 10 ---
Macroni (55/2)
Water (105/2)
Salt (100/3)
Cheddar Cheese (55)
Bowtie Pasta (40)
Swiss Cheese (40/3)
Marinara (35)
Spinach (15/2)
Crushed Red Pepper (5/2)
Mozzarella Cheese (20)
Provolone (15/2)

AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Similar 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