Consider the class hierarchy on the last page of this assignment. It is a class hierarchy of food products, including FreshVegetable and CannedItem.
A Package is also a product and is a container of multiple products.
• We wish to use the visitor pattern to implement two operations on the product hierarchy.
• The first operation is to find the cheapest item in a product, which we implement using the CheapestVisitor.
• The second operation is to reduce the price of CannedItem and FreshVegetable items in a product by specified amounts.
We implement this using the ReducePriceVisitor.
You are provided with the main program main.cpp and the completed header file for the Product hierarchy.
Note that the Package is implemented using the vector class from the c++ stl library.
The ProductVisitor hierarchy is partially implemented in ProductVisitor.h.
You need to complete the implementation of the CheapestVisitor and ReducePriceVisitor classes.
You are also required to implement the following methods in the file called ProductVisitor.cpp:
1. void ProductVisitor::visit(Package *p)
2. void CheapestVisitor::visit(FreshVegetable *p)
3. void ReducePriceVisitor::visit(FreshVegetable *p)
4. void ReducePriceVisitor::visit(CannedItem *p)
5. double CheapestVisitor::getMinPrice() // return the price of the cheapest item
6. Item *CheapestVisitor::getMinItem() // return a pointer to the cheapest item
7. void CheapestVisitor::reset() // reset the CheapestVisitor before finding another cheapest item
• All points where implementation is required are marked by the comment TO BE COMPLETED
• Compile the code using cc -o product.exe main.cpp ProductVisitor.cpp
• There are two test functions in main.cpp - change main() to try each one.