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)
to generate a solution
a solution
- Inheritance, Polymorphism, ArrayLists, Throwing Exceptions The UML diagram below shows a set of classes designed to represent a music collection from 1995. The constructors and methods all function in the standard way, except: The equipmentRequired method should return “Record Player” or “CD Player” as appropriate.The getAlbum method of the NinetiesMusicCollection class accepts an index and returns the corresponding Album object. This method throws an IllegalArgumentException if the index is out of range. (This is the only exception you have to throw anywhere in your code.)In the NinetiesMusicCollection constructor, you can assume the ArrayList<Album> object passed as an argument is not null . Don’t worry about privacy leaks.Implement this set of classes in Java. Note the italics on the Class name “Album” and the method name “equipmentRequired” in the Album class.arrow_forwardImplement a nested class composition relationship between any two class types from the following list: Advisor Вook Classroom Department Friend Grade School Student Teacher Tutor Write all necessary code for both classes to demonstrate a nested composition relationship including the following: a. one encapsulated data member for each class b. inline default constructor using constructor delegation for each class c. inline one-parameter constructor for each class d. inline accessors for all data members e. inline mutators for all data membersarrow_forwardJava- Suppose that Vehicle is a class and Car is a new class that extends Vehicle. Write a description of which kind of assignments are permitted between Car and Vehicle variables.arrow_forward
- Goal 1: Update the Fractions Class Here we will overload two functions that will used by the Recipe class later: multipliedBy, dividedBy Previously, these functions took a Fraction object as a parameter. Now 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 (affecting numerator/denominator of the returned object). 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 Now add a private member variable of type int to denote the serving size and initialize it to 1. This means all recipes are initially constructed for a single serving. Update the overloaded extraction operator (<<) to include the serving size (sample output below for an example of formatting) . New Member functions to the Recipe Class: 1. Add four member functions…arrow_forwardg) Make a class Class (as in a class of students, not a class as in a class of objects) that stores several Student objects. Store a list of students in an attribute called students. The initializer method should initialize the class as an empty class (no students). Implement a method add_student() that takes an object of class Student and adds it to class. Implement method pass_rate() that determines the fraction of students that pass the class (have a grade of >= 6). python code!!arrow_forwardImplement the following parking permit class using java It has a dependency on the car class, no need to implement the car class. Use the diagram for refrencearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education