Question: Define a class called Person with private members first, and last both of type string. The class also has the public member functions set0, print(),







Define a class called Person with private members first, and last both of type string. The class also has the public member functions set0, print(), getFirstName(, getLastName ), and a default parameterized constructor. Define a class called Product with private members name, code both of type string, price, quantity both of type integer, and the function calculateCost() which calculates the cost of a product (price * quantity). The class also has the public member functions set(), print(ofstream\&), getName(), getCode0, getPrice 0 , getQuentity0, and a default parameterized constructor. Define a class called Selasperson that publicly inherits the class Person. The class has the private members Id, numberOfProducts both of type integer, salary of type double, productsSold [ ] (an array of type Product and size maxSize = 10), and the member function calculateSalayy . The class also has the public members ser(ifstream\&), print(ofstream\&), and getSalaryO. The salary is calculated as 6% of the sum of price * quantiry of all products sold. Implement all member functions of the three classes, enforcing the least privileged principle. The following driver produces the given sample of output: ifstream inFile("productin.txt", ios:-in); ofstream outFile("productOut.txt", ios::out); int main0 f Salesperson salespersonsList[10]; int i, noOfSalespersons; inFile > noOfSalespersons: for(i-0; ii++) salespersonsList[i].print(outFile): return 0; Sample Input: Content of the text file productIn.txt 3 Lisa Miller 8902384 Bed BB01430 4 Mattres BM03 2105 Quilt BQ021303 Pillow BP01258 Bill Wilton 7983245 Linen BL0278 6 Quilt BQ021305 Curtains BC033154 Pillow BP01 2510 Pillow BP01 2510 Wardrobe BW01 1702 Dandy Goat 7463336 Wardrobe BW01 1701 Mattres BM03 2102 Pillow BP0125 4 Sample Output: Content of the text file productOut.txt Salesperson Name: Lisa Miller Salesperson ID: 890238 Number of products soled: 4 Sample Output: Content of the text file productOut.txt Salesperson Name: Lisa Miller Salesperson ID: 890238 Number of products soled: 4 Total salary: 201.6 _*_*_*_*_*_*_*_*__*___*_*_*_*_*_*_*_*_*_* Salesperson Name: Bill Wilton Salesperson ID: 798324 Number of products soled: 5 Salesperson Name: Dandy Goat Salesperson ID: 746333 Number of products soled: 6T BP01BC03BQ02BL02PillowCurtainsQuiltLinen253151307845241001575260312 Total salary: 170.22
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
