Question: Please implement in c + + using customer and item structs. Please make the application beginner friendly. Project 5 Online Groceries PART 2 In this
Please implement in c using customer and item structs. Please make the application beginner friendly.
Project Online Groceries PART
In this program, you add to part This project will print a report of online orders. There are input files to process:
customers.txt part
items.txt part
orders.txt
From part :
The first file holds customer data in a single text line the following:
Kai Antonikov, Prairie Rose Street,Philadelphia,PAkantonikov@shared.com
The data fields are the customer id name, street, city, state, zip, phone, and email.
The file items.txt has fields itemid description, and price:
Almonds Ground Blanched,
New in Part :
Orders.txt holds lines per order. The first line contains the customer id order number, order date, and then a variablelength list of itemidquantity pairs:
In the line above items of product # were ordered, of product # etc. Note that all fields in all files are commaseparated, and that the itemidquantity pairs in orders.txt are separated by a dash.
The second line contains payment information in the form of payment code, and payment information. There are types of payments:
credit card card number & expiration date
PayPal paypalid only
wire transfer bankid & accountid
Examples:
cfeehams
Requirements
Write all code in a single file, groceries.cpp
Define all classes with all functions inline insitu within each class
Payment is an abstract class. Its derived classes must override printdetail which returns a string which becomes part of printing an order as shown below. Order::printorder calls Customer::printdetail and Payment::printdetail to do its work.
Provided main function:
int main
readcustomerscustomerstxt;
readitemsitemstxt;
readordersorderstxt;
ofstream ofsorderreport.txt;
for const auto& order: orders
ofs order.printorder endl;
The global functions readcustomers and readitems from part create global vectors of Customer and Item objects obtained from file input. The readorders function populates a global std::list with Order objects from file input.
Most of the work is done in readorders and Order::printorder. Order::readorders gathers all info for the order and then adds a new Order object to the global std::list named orders. Orders must be a list and not a vector.
Your output should be in a file named orderreport.txt that looks like the following:
Order # Date:
Amount: $ Paid by Credit card exp.
Customer ID #:
Yolanda McAlarney, ph email: ymcalarneyu@wordpress.com
Corscot Hill
Albuquerque, NM
Order Detail:
Item : "Syrup Monin Swiss Choclate", @
Item : "Wine Red Cooking", @
Item : "Pastry Lemon Danish Mini", @
Item : "Beef Short Ribs", @
Item : "Bread Crumbs Bulk", @
Item : "Waffle Stix", @
Item : "Longos Burritos", @
Item : "Lemonade Strawberry Ml @
Item : "Pie Filling Cherry", @
Item : "Oil Peanut", @
Item : "Pasta Rotini Colour Dry", @
Item : "Peach Halves", @
Item : "Black Currants", @
Item : "Juice Propel Sport", @
Item : "Pie Shells @
Item : "Quail Whole Boneless", @
Item : "Beef Flat Iron Steak", @
Item : "Bread Country Roll", @
Each order begins with a dashed line and has parts, each followed by an empty line. The orders appear in the order they are read from the file, but the items in each order are sorted by itemid
I have provided a file, split.h which contains a split function that returns all fields that were separated by some character as a vector of strings. You can also use this function to separate the itemidquantity pairs using a dash as the split character.
To call std::sort to sort the line items of an order, #include the header and add the following compare function to your LineItem class:
friend bool operatorconst LineItem& item const LineItem& item
return itemitemid itemitemid;
Note that to achieve runtime polymorphism with the Payment objects, the payment member of Order must be a pointer. In our case, the concrete Payment instances Credit PayPal, WireTransfer are allocated on the heap using the new operator. Your readorders function needs to check the payment code or and create the appropriate payment subtype, storing it in a Payment Then readorders adds a new Order object to your global list of orders.
Order should have a destructor that deletes its payment pointer to avoid memory leaks.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
