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

The FoodItem class represents an edible food product. FoodItem bagel(\"onion bag

ID: 3558266 • Letter: T

Question

The FoodItem class represents an edible food product.

FoodItem bagel("onion bagel", FoodItem::BREAKFAST);

Here are the declaration (.h) and implementation (.cpp) files for the FoodItem class:

// Fooditem.h - implementation file
#ifndef FOODITEM_H
#define FOODITEM_H

#include <iostream>
using namespace std;

class FoodItem
{
public:
  enum KIND {BREAKFAST, LUNCH, DINNER, SNACK };
FoodItem(string name, KIND kindOfItem);
  string getName() const;
  KIND getKind() const;

private:
  KIND myKind;
  string myName;
};

#endif // !FOODITEM_H

// Fooditem.cpp - implementation file
#include <iostream>
#include "FoodItem.h

using namespace std;

FoodItem::FoodItem(string name, KIND kindOfItem): myName(name), myKind(kindOfItem)
{}

FoodItem::KIND FoodItem::getKind() const
{
  return myKind;
}

string FoodItem::getName() const
{
  return myName;
}

The Pancakes class inherits from the FoodItem class and adds one integer member variable

Question 1. 1.

The FoodItem class represents an edible food product.

FoodItem bagel("onion bagel", FoodItem::BREAKFAST);

Here are the declaration (.h) and implementation (.cpp) files for the FoodItem class:

// Fooditem.h - implementation file
#ifndef FOODITEM_H
#define FOODITEM_H

#include <iostream>
using namespace std;

class FoodItem
{
public:
  enum KIND {BREAKFAST, LUNCH, DINNER, SNACK };
FoodItem(string name, KIND kindOfItem);
  string getName() const;
  KIND getKind() const;

private:
  KIND myKind;
  string myName;
};

#endif // !FOODITEM_H

// Fooditem.cpp - implementation file
#include <iostream>
#include "FoodItem.h

using namespace std;

FoodItem::FoodItem(string name, KIND kindOfItem): myName(name), myKind(kindOfItem)
{}

FoodItem::KIND FoodItem::getKind() const
{
  return myKind;
}

string FoodItem::getName() const
{
  return myName;
}

The Pancakes class inherits from the FoodItem class and adds one integer member variable

Explanation / Answer

// Pancakes.h file
class Pancakes : public FoodItem
{
public:
Pancakes(int number = 3);
private:
int howMany;
}

// Pancakes.cpp file.
Pancakes::Pancakes(int number):FoodItem("Pancakes",FoodItem::BREAKFAST),howMany(number)
{

}

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