Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Complete Burrito.cpp Source.cpp below #include // Used for cin and cout #include Burrito.h using namespace std; // making life easier so taht we do not
Complete Burrito.cpp
Source.cpp below
#include // Used for cin and cout
#include "Burrito.h"
using namespace std; // making life easier so taht we do not need to use std::cin , std::cout, etc.
int main()
{
Burrito b1("Asada", false);
cout << "your result is "<< b1.price() << ". It should be 5" << endl;
b1.add_cheese();
cout << "your result is " << b1.price() << ". It should be 6" << endl;
b1.change_meat("Nada");
cout << "your result is " << b1.price() << ". It should be 3" << endl;
Burrito b2; // Special syntax for constructor with no parameters
cout << "your result is " << b2.price() << ". It should be 2" << endl;
b2.add_cheese();
cout << "your result is " << b2.price() << ". It should be 3" << endl;
b2.change_meat("AlPastor");
cout << "your result is " << b2.price() << ". It should be 5" << endl;
b2.change_meat("Asada");
cout << "your result is " << b2.price() << ". It should be 6" << endl;
b2.remove_cheese();
cout << "your result is " << b2.price() << ". It should be 5" << endl;
}
Burrito.cpp below
#include "burrito.h"
Burrito::Burrito(string m, bool c)
{
// Initializing instance variables using constructor parameters
meatType = m;
hasCheese = c;
}
Burrito::Burrito()
{
// Initializing instance variables without using constructor parameters
this->meatType = "Nada";
this->hasCheese = false;
}
string Burrito::meat()
{
return meatType;
}
Need other methods
Burrito.h below
#include "string"
using namespace std;
class Burrito
{
public:
// Constructor.
// Creates a burrito with the specified ingredients.
Burrito(string m, bool cheese);
// Constructor.
// Creates a burrito with no (Nada) meat and no cheese.
Burrito();
// Changes the burrito's meat to the parameter meat.
void change_meat(string m);
// Adds/removes cheese to/from the burrito.
void add_cheese();
void remove_cheese();
// Returns the burrito's current meat/cheese
string meat();
bool cheese();
// Computes the price.
// A burrito with no meat/cheese costs $2.
// Cheese is $1 extra.
// Meat costs $2, and Asada is $1 extra.
int price();
private:
string meatType; // meatType could be any of these: Pollo, Asada, AlPastor, Nada, etc
bool hasCheese;
};
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