Question
Using C++ The general idea is you will have an Oven, a Person, and a Cookie. You will give the cookie to the oven to
Using C++ The general idea is you will have an Oven, a Person, and a Cookie. You will give the cookie to the oven to cook. You will then give the cookie to the person to eat. The Whole Point of the assignment is to show that when Oven does something to the Cookie, the Person can see the change when the Cookie gets to them. The Main looks like this #include "stdafx.h" // Here is the file with main in it like normal. Main is always the starting point of the application. // If you want to add a class to your project, right click on the project and just pick Add->Class. // Then you just need to put a name in the very first field and hit ok. VS will make the h and cpp files // and put them in the right place. // Just like how you need to include iostream to use cout, you need to include your new h files if you want to use their class // HOWEVER. If you are in an h file and only want to _mention_ a class, then you do a "forward declaration". Details in Oven. #include "Cookie.h" #include "Oven.h" #include "Person.h" #include int main() { // For the love of Chuck follow this outline. I am grading these steps in the outline. The outline below. That you have to use. // I'm 100% laying out exactly what you need to do, but I'm making you write the prototypes and methods // 1) Make an Oven object // 2) Make a Person pointer and assign a dynamically allocated Person object to it // 3) Make a Cookie pointer and leave it null // 4) Ask the user to enter the flavor of cookie they want. You need to handle multiple words so use getline, not >> // 5) Create a new cookie object. The cookie's constructor takes a string argument for the flavor // 6) Make Oven and Cookie interact. Oven should have a method that takes a COOKIE POINTER as an argument that cooks the cookie // 7) Make Person and Cookie interact. Person should have a method that takes a COOKIE POINTER as an argument, and checks if the cookie is cooked // 8) Delete any objects you created. One new, one delete. return 0; }
Cookie.h looks like this:
#pragma once class Cookie { // Cookie needs a property for the flavor string // Cookie needs a property for a bool to track if it is cooked or not public: // Cookie needs a constructor that takes a string for the flavor // Cookie needs to NOT have a default constructor Cookie(); ~Cookie(); // Since cookie properties are private, we need methods to set and get them. BUT, the cookie's flavor can't change after // creation, so there should not be a settor for flavor. };
Oven.h looks like this:
#pragma once // Oven is going to need to mention the cookie class since it is an argument in its method. But h files need to be very careful when including h files. // If A includes B, B includes C, and C includes A, then VS completely freaks out. "Circular dependency." It won't compile and it won't be able to figure out a good error message. // So when a cpp file wants to USE a class, like it wants to make objects and call methods, it includes the h file. // When an h file wants to MENTION a class, as in it just wants to say the word, it "forward declares" the class. It tells VS "Trust me, this is a class in another file." // If you think about it, this looks like a prototype of a function. A prototype is the definition and then a semicolon instead of {}. class Cookie; class Oven { public: Oven(); ~Oven(); // Oven has a method that takes a cookie pointer as an argument. Cookie has a flag representing if it is cooked if you flip over there. // This method should set that flag to true by using its setter. };
And Person.h looks like this:
#pragma once class Person { public: Person(); ~Person(); // Person has a method that takes a cookie pointer as an argument. Cookie has a flag for whether or not it is cooked. // This method will check that flag using cookie's getter and cout a message saying if it is cooked or not. };
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started