We have the following two classes called Receipt and Item.
class Item
{
private:
int ID;
double price;
int units;
public:
Item(int, double, int); //Need to change based on array requirement
void setID(int);
int getID();
void setPrice(double);
double getPrice();
void setUnits(int);
int getUnits();
void displayItemInfo();
double computePricePerItem();
};
class Receipt
{
private:
string shopperName;
Item * shoppingList;
const int maxItems = 20;
int numItems;
public:
Receipt(string);
void setShopperName(string);
string getShopperName();
void setShoppingList(Item *);
Item * getShoppingList() const;
int getNumItems();
void addItem(Item);
void displayTheShoppingList();
double computeTotalCharge();
};
Use the above specifications to create the proper header files/ specification files: Item.h and Receipt.h for these two classes, feel free to define some of the functions of your choice as inline functions.
Define their COMPLETE implementation files: Item.cpp and Receipt.cpp based on these specifications.
Finally create your driver file, the one that contains the main function to write this program that is described below:
You are asked to write a program that helps a small farmer stand in a farmer's market to process their weekly sales data. Here is the list of some specifications about their products:
8 2.99
[name][tab][# of items ordered][tab][ID][tab][unit]. .[Enter]
Johnson 2 4 3 8 1
Each line of the weeklySales.txt file will be used to instantiate an object of type Receipt. Notice that class Receipt has a dynamically allocated array of Item objects.
You are asked to write a program that reads the information in the file itemInfo.txt into an array of size 11, whose each index matches the ID of the item and the element with that index contains the price of that item's ID. So for example based on the above sample line of this file:
8 2.99
We will have in index 8 of this array the value of 2.99. Call this array of type double, pricePerID.
You will use this array as a reference to retrieve the price of different items based on their ID's/ indices.
The plan is to have a vector of type Receipt to store the data in the sales file.
So go ahead and create your vector of type Receipt to be populated via the sales file.
So start reading from the file weeklySales.txt with the goal of creating an object of type Receipt from the data on each line.
This process includes the following general steps:
When you have done the above steps successfully, write segments of code to process the following menu:
1. Display the total charges per receipts.
2. Display the tally result per Item ID’s.
3. What appears to be the most popular item(by ID) of this farmer stand, Based on this sales record?
4. Defective Product: No charge based on Item ID:
Enter the item ID 1-10:
5. BONUS OPTION (+8 points): Apply the following promotion on existing sales records: Buy 5 units or more of the same item and get one item free (i.e. get credit for one item).
6. Exit.
Notice, both options 4 and the BONUS OPTION will alter the individual Receipts of your Receipt vector. So if I choose either option, and then choose option 1 right after, I should be able to see the difference in the total dollar amount charged per Receipt.
Notice that option 4 does not change the original price of that item in our pricePerID array, we assume this only applies to that item's sale in the weekly data we are processing.
For the sake of brevity, you do not need to worry about how the BONUS OPTION affects your tally process. We assume that the sellers have some other accounting provisions to account for the items they give away for free!
Do not change the classes, this should be a promotion that is applied in the main function.