Question: Can you please answer it clearly with an explanation if possible? Q/ Define a class called Person with private members first , and last both
Can you please answer it clearly with an explanation if possible?
Q/ Define a class called Person with private members first, and last both of type string. The class also has the public member functions set(), 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(), getCode(), getPrice(), getQuentity(), 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 calculateSalary(). The class also has the public members set(ifstream&), print(ofstream&), and getSalary().
The salary is calculated as 6% of the sum of price * quantity 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 main()
{
Salesperson salespersonsList[10];
int i, noOfSalespersons;
inFile >> noOfSalespersons;
for(i=0; i salespersonsList[i].set(inFile); for(i=0; i salespersonsList[i].print(outFile); return 0; } Sample Input: Content of the text file productIn.txt 3 Lisa Miller 890238 4 Bed BB01 430 4 Mattres BM03 210 5 Quilt BQ02 130 3 Pillow BP01 25 8 Bill Wilton 798324 5 Linen BL02 78 6 Quilt BQ02 130 5 Curtains BC03 315 4 Pillow BP01 25 10 Wardrobe BW01 170 2 Dandy Goat 746333 6 Wardrobe BW01 170 1 Mattres BM03 210 2 Pillow BP01 25 4 Curtains BC03 315 5 Quilt BQ02 130 2 Linen BL02 78 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
