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 5 Online Groceries PART 2
In this program, you add to part 1. This project will print a report of online orders. There are 3 input files to process:
customers.txt (part 1)
items.txt (part 1)
orders.txt
(From part 1):
The first file holds customer data in a single text line the following:
810003,Kai Antonikov,31 Prairie Rose Street,Philadelphia,PA,19196,215-975-7421,kantonikov0@4shared.com
The data fields are the customer id, name, street, city, state, zip, phone, and email.
The file items.txt has fields item_id, description, and price:
57464,Almonds Ground Blanched,2.99
(New in Part 2):
Orders.txt holds 2 lines per order. The first line contains the customer id, order number, order date, and then a variable-length list of item_idquantity pairs:
762212,1,2020-03-15,10951-3,64612-2,57544-1,80145-1,27515-2,16736-1,79758-2,29286-2,51822-3,39096-1,32641-3,...
In the line above 3 items of product #10951 were ordered, 2 of product #64612, etc. Note that all fields in all files are comma-separated, and that the item_idquantity 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 3 types of payments:
1= credit card (card number & expiration date)
2= PayPal (paypal_id only)
3= wire transfer (bank_id & account_id)
Examples:
1,373975319551257,12-2023
2,cfeeham3s
3,72-2201515,68196-140
Requirements
Write all code in a single file, groceries.cpp
Define all classes with all functions inline (in-situ within each class)
Payment is an abstract class. Its derived classes must override print_detail which returns a string which becomes part of printing an order as shown below. Order::print_order calls Customer::print_detail and Payment::print_detail to do its work.
Provided main function:
int main(){
read_customers("customers.txt");
read_items("items.txt");
read_orders("orders.txt");
ofstream ofs("order_report.txt");
for (const auto& order: orders)
ofs << order.print_order()<< endl;
}
The global functions read_customers and read_items from part 1 create global vectors of Customer and Item objects obtained from file input. The read_orders function populates a global std::list with Order objects from file input.
Most of the work is done in read_orders and Order::print_order. Order::read_orders 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 order_report.txt that looks like the following:
===========================
Order #1, Date: 2020-03-15
Amount: $100.23, Paid by Credit card 373975319551257, exp. 12-2023
Customer ID #762212:
Yolanda McAlarney, ph.505-136-7715, email: ymcalarney2u@wordpress.com
705 Corscot Hill
Albuquerque, NM 87190
Order Detail:
Item 10951: "Syrup - Monin Swiss Choclate", 3 @ 3.00
Item 16736: "Wine - Red Cooking", 1 @ 2.00
Item 16974: "Pastry - Lemon Danish - Mini", 3 @ 1.19
Item 23022: "Beef - Short Ribs", 1 @ 5.00
Item 26461: "Bread - Crumbs Bulk", 1 @ 3.00
Item 26860: "Waffle Stix", 2 @ 2.99
Item 27515: "Longos - Burritos", 2 @ 4.00
Item 29286: "Lemonade - Strawberry 591 Ml",2 @ 2.25
Item 32641: "Pie Filling - Cherry", 3 @ 0.89
Item 39096: "Oil - Peanut", 1 @ 0.95
Item 51822: "Pasta - Rotini Colour Dry", 3 @ 1.19
Item 57544: "Peach - Halves", 1 @ 0.79
Item 63725: "Black Currants", 3 @ 0.79
Item 64007: "Juice - Propel Sport", 2 @ 1.99
Item 64612: "Pie Shells 10",2 @ 7.00
Item 75536: "Quail - Whole Boneless", 2 @ 8.79
Item 79758: "Beef Flat Iron Steak", 2 @ 5.49
Item 80145: "Bread - Country Roll", 1 @ 2.29
===========================
Each order begins with a dashed line and has 3 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 item_id.
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 item_id-quantity 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 operator<(const LineItem& item1, const LineItem& item2){
return item1.item_id < item2.item_id;
}
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 read_orders function needs to check the payment code (1,2, or 3) and create the appropriate payment subtype, storing it in a Payment*. Then read_orders 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 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 Programming Questions!