Question
I need help with this problem. Please write this in 3 files (1 header, 1 implementation and 1 driver file. You are going to create
I need help with this problem.
Please write this in 3 files (1 header, 1 implementation and 1 driver file.
You are going to create a FruitTree class. The FruitTree class has the following variables:
- string name
- Represents the specie name of the fruit tree (no preconditions)
- string description
- Describes the fruit and tree care (no preconditions)
- bool isEdible
- Set to true if you can eat the fruit, false otherwise
- bool best4Jam
- Set to true if this taste better as a jam and false otherwise
The class will have the following member functions:
- void setName( string new_name);
- Assigns new_name to the class's name
- void setDescription(string new_description);
- Assigns new_description to the class's description
- void setIsEdible(bool new_edible);
- Assigns new_edible to the class's isEdible variable
- void setBest4Jam(bool new_jam);
- Assigns new_jam to the class's best4Jam variable
- string getName();
- returns name
- string getDescription();
- returns description
- bool getBest4Jam();
- returns best4Jam
- bool getIsEdible();
- returns isEdible
- void printInfo();
- Displays the name, followed by the description. Displays "This fruit is edible," if the isEdible is set to true and otherwise displays "Do not eat the fruit." If best4Jam is true, then the following is displayed as well "Best eaten as a jam"
Lastly, it will have the following constructors:
- FruitTree()
- Assigns "" to the string variables and false to the bool variables
- FruitTree(string init_name, string init_description, bool init_edible, bool init_jam);
- Assigns the input values to the corresponding class variables.
For the driver file, create a meyerLemon FruitTree object. Initialize its variables to the following information:
Name: Meyer Lemon
Description: "Sweeter lemon. Great for lemon treats"
isEdible: true
best4Jam: false
Then display the object's information. After this, set the name of the meyerLemon object to "Lime" and display the object's information again.
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