Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ During the summer, I am self learning C++. I came across this problem. 1) ma

ID: 3913230 • Letter: C

Question

C++

During the summer, I am self learning C++. I came across this problem.

1) make an Oven object
2) makes 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 take 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.

#include "stdafx.h"
#include "Cookie.h"
#include "Oven.h"
#include "Person.h"
#include <iostream>

int main
{
return 0;
}

Explanation / Answer

Oven.h

#include <iostream>

#include<string>

class Oven

{

public:

int Cook_Cookie(string flavor);

};

Oven.cpp

#include <iostream>

#include<string>

#include "stdafx.h"

#include "Oven.h"

using namespace std;

int Oven::Cook_Cookie(string flavor)

{

cout<<"Preparing "<<flavor<<" flavoured cookie . . ."<<endl;

return true;

}

Cookie.h

#include <iostream>

#include<string>

class Cookie

{

public:

string flavor;

bool isCooked;

Cookie(string s);

};

Cookie.cpp

#include <iostream>

#include<string>

#include "stdafx.h"

#include "Cookie.h"

using namespace std;

Cookie::Cookie(string s)

{

Cookie::flavor = s;

Cookie::isCooked = true;

}

Person.h

#include <iostream>

class Person

{

public:

void check_status(bool status);

};

Person.cpp

#include <iostream>

#include "stdafx.h"

#include "Person.h"

using namespace std;

void Person::check_status(bool status)

{

if(status == true)

{

cout<< "Your cookie is ready! You may taste it."<< endl;

}

else{

cout<< "Sorry. Your cookie is not ready" << endl;

}

}

Main.cpp

#include <iostream>

#include<string>

#include "stdafx.h"

#include "Oven.h"

#include "Cookie.h"

#include "Person.h"

using namespace std;

int main()

{

Oven ovenobject;

Person* personobject = new Person();

Cookie* cookie_ptr;

string str;

cout<<"Enter a flavor of your choice for your cookie: "<<endl;

getline(cin, str);

//return if flavor does not contain any letters

int flag = 0;

for(int c=0; c<str.length(); c++)

{

if(isalpha(str[c])) flag = 1;

}

if (flag == 0)

{

cout<<"Invalid flavor"<<endl;

return 0;

}

Cookie cookieobject(str);

cookie_ptr = &cookieobject;

cookie_ptr->flavor = ovenobject.Cook_Cookie(cookie_ptr->flavor);

personobject->check_status(cookie_ptr->isCooked);

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote