Question: Produce.h #include #include using namespace std; class Produce { protected: string name, origin; double unitPrice; public: Produce(); Produce(string nameIn, string originIn, double price); void setValues(string

 Produce.h #include #include using namespace std; class Produce { protected: string
Produce.h
#include
#include
using namespace std;
class Produce {
protected:
string name, origin;
double unitPrice;
public:
Produce();
Produce(string nameIn, string originIn, double price);
void setValues(string nameIn, string originIn, double price);
string getName();
string getOrigin();
double getUnitPrice();
double getPrice(double lbs);
void display();
};
ostream& operator
*****************************************************
Produce.cpp
#include "Produce.h"
using namespace std;
Produce::Produce() {
// Default values
name = "No name input";
origin = "No origin input";
unitPrice = 0;
}
Produce::Produce(string nameIn, string originIn, double price) {
// Values passed are stored into data members of Produce
name = nameIn;
origin = originIn;
unitPrice = price;
}
void Produce::setValues(string nameIn, string originIn, double price) {
// Values passed are stored into data members of Produce
name = nameIn;
origin = originIn;
unitPrice = price;
}
string Produce::getName() {
return name;
}
string Produce::getOrigin() {
return origin;
}
double Produce::getUnitPrice() {
return unitPrice;
}
double Produce::getPrice(double lbs) {
// Price is the number of pounds times the price per unit
return unitPrice * lbs;
}
void Produce::display() {
// Displays the name, origin, and price per unit of Produce
cout
}
ostream& operator
// Displays the name, origin, and price per unit of Produce
return out
}
Using the provided class Produce you can find it on D2L), create a new class that will inherit from Produce. The child class will be called Fruit. This class will have the following data member: sugarContent. The class will also have its own display function to also display the per unit sugarContent while calling the display function from the parent (see the output), and member function get TotalSugars that will return the total sugar content based on the following equation: sugarContent * pounds Use the following main function to achieve the desired output: #include #include "Produce.h" using namespace std; int main() { Fruit orange("Orange", "Florida", 0.45, 9); Produce apple("Apple", "California", 0.35); double sugars; double pounds=2.5; orange.display(); cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!