Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

im not sure how to do start on this program. im still kinda confussed on pointers so if you can put notes with the anwser

im not sure how to do start on this program. im still kinda confussed on pointers so if you can put notes with the anwser that would be great

////////

Cookie.h

#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

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

};

//////

Person.h

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

};

/////

Cookie.cpp

#include "pch.h"

#include "Cookie.h"

#include

#include

//using namespace std;

Cookie::Cookie(std::string name)

{

}

Cookie::~Cookie()

{

any delete;

}

/////

Oven.cpp

#include "pch.h" #include "Oven.h"

// The most confusing part of the h-cpp file system is that "Oven::" below. The colon-colon symbol is the "scope" operator. // Since Oven's declaration is in a different file, and these methods are outside it, we need to tell VS what method we are writing. // Think of it as apostrophe-s again. "void Oven::NewFunc()". Whose NewFunc is this? It is Oven's NewFunc.

Oven::Oven() {

}

Oven::~Oven() {

}

/////

Person.cpp

#include "pch.h" #include "Person.h"

Person::Person() {

}

Person::~Person() {

}

/////

C for Cookie.cpp

#include "pch.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;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions

Question

List the steps in the succession management process.

Answered: 1 week ago