Question
Complete the program that receives tweets information for an unknown number of users. This information includes user_name, likes_count, retweets_count, replies_count, and share_videos (Y/N) on Twitter.
Complete the program that receives tweets information for an unknown number of users. This information includes user_name, likes_count, retweets_count, replies_count, and share_videos (Y/N) on Twitter. At the end of the entry process, the user presses enter instead of entering the user name to end the program. This will end the program and display all the tweets' reports for the entered users. I've provided all code below and make sure not to use any library other than iostream, cstdio, cstring
This module is fully provided. Please do not change any of its code. Review it and make sure you understand how the functions that you have developed are being used. Implementation This application is implemented in three modules: main Module (fully provided) Tools Module (fully provided) Customer Module (implement) Your task is to complete the implementation of the Customer module to provide the functions needed in the main module. You may freely use or copy any logic or code needed from the LAB section Structs to be used: struct Customers { char user_name[21]; int retweets_count;; int likes_count; int replies_count; char share_videos; }; struct CustomersRecord { Customers* ptr_rec; // Dynamically holds the customers' tweets report. int noOfRecords; }; Required functions (mandatory) Implement 2 overloads of a function called EmptyRecord void EmptyRecord(...........); Sets Customer data members to an empty state void EmptyRecord(...........); Sets CustomersRecord data members to an empty state Implement the follwoing five functions 1. bool read(Customers& rec); Requests to enter "user name: " and then reads a CString into the name of the Customer reference. If the user enters a value of the user name, then it will read the likes_count, retweets_count, replies_count, and share_videos of the Customer and returns true. Otherwise, if the CString for the name is empty after entry, the function returns false. 2. void read(char* str, int len); Reads a CString into the str pointer up to len characters. This function is already implemented and is provided in the Customer module 3. void addCustomer(CustomersRecord& t_rec, const Customers& c_rec); Adds a Customer to the dynamically allocated memory of customers in CustomersRecord 4. void display(const Customers& c_rec); Prints the Customer information as follows: user name comma and space ", " likes comma and space ", " re-tweets comma and space ", " replies comma and space ", " share videos (y/n) new line " " 5. void display(const CustomersRecord& t_rec) It prints a row number with a period before each user name. Then, it prints all the customers' records.
Customer.cpp = #define _CRT_SECURE_NO_WARNINGS #include using namespace std; #include "Customer.h" #include "Tools.h" namespace sdds { // complete void read(char* str, int len) { // Fully provided if (cin.peek() == '') { cin.ignore(); } cin.getline(str, len); } // complete }
Customer.h = #ifndef SDDS_CUSTOMER_H_ #define SDDS_CUSTOMER_H_ namespace sdds { struct Customers { char user_name[21]; int retweets_count;; int likes_count; int replies_count; char share_videos; }; struct CustomersRecord { Customers* ptr_rec; // Dynamically holds the customers' tweets' report. int noOfRecords; }; void read(char* str, int len); // to be completed } #endif
Tools.cpp = #define _CRT_SECURE_NO_WARNINGS #include "Tools.h" namespace sdds { void strCpy(char* str1, const char* str2) { while(*str2) { *str1++ = *str2++; } *str1 = 0; } }
Tools.h = #ifndef SDDS_TOOLS_H_ #define SDDS_TOOLS_H_ namespace sdds { void strCpy(char* des, const char* src); }#endif
main.cpp = // Please don't change this file // Please don't change this file // This file is to test your source code #include #include "Customer.h" using namespace std; using namespace sdds; int main() { bool Check = false; Customers c_rec; EmptyRecord(c_rec); CustomersRecord t_rec; EmptyRecord(t_rec); cout << "--------- Customers records entry ------------------" << endl; while (!Check) { cout << endl<<"Enter customer information (to exit, press Enter): " << endl; if (read(c_rec)) { addCustomer(t_rec, c_rec); } else { Check = true; } } cout << "---------------------------------------------------------" << endl; cout << " Users' tweets report " << endl; cout << " user name, likes, re-tweets, replies, share videos (y/n)" << endl; cout << "---------------------------------------------------------" << endl; display(t_rec); cout << "---------------------------------------------------------" << endl; cout << " Report was successfully created " << endl; delete[] t_rec.ptr_rec; cout << "Dynamically allocated memory was successfully deallocated" << endl; cout << "---------------------------------------------------------" << endl; }
OUTPUT MUST MATCH --------- Customers records entry ------------------ Enter customer information (to exit, press Enter): Enter User name: zebaism Enter likes_count: 595 Enter retweets_count: 234 Enter replies_count: 27 Enter share videos (y/n): n Enter customer information (to exit, press Enter): Enter User name: rohanv Enter likes_count: 12 Enter retweets_count: 0 Enter replies_count: 1 Enter share videos (y/n): n Enter customer information (to exit, press Enter): Enter User name: frank Enter likes_count: 15 Enter retweets_count: 2 Enter replies_count: 0 Enter share videos (y/n): n Enter customer information (to exit, press Enter): Enter User name: desibrah Enter likes_count: 39 Enter retweets_count: 19 Enter replies_count: 2 Enter share videos (y/n): y Enter customer information (to exit, press Enter): Enter User name: sheetut Enter likes_count: 1 Enter retweets_count: 0 Enter replies_count: 3 Enter share videos (y/n): y Enter customer information (to exit, press Enter): Enter User name: --------------------------------------------------------- Users' tweets report user name, likes, re-tweets, replies, share videos (y/n) --------------------------------------------------------- 1. zebaism, 595, 234, 27, n 2. rohanv, 12, 0, 1, n 3. frank, 15, 2, 0, n 4. desibrah, 39, 19, 2, y 5. sheetut, 1, 0, 3, y --------------------------------------------------------- Report was successfully created Dynamically allocated memory was successfully deallocated ---------------------------------------------------------
Please submit:
main.cpp (please do not modify this file).
Customer.cpp
Customer.h
Tools.cpp
Tools.h
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Heres the implementation for the Customercpp file include include Customerh include Toolsh namespace ...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