I need help with storing data in a singly-linked list where the nodes in the list correspond to each day in a 31-day month. An employee passes in between 1 and 5 slips per day every time they sell a product. These slips must include Product ID, staffID, and total dollar amount of products sold in a day. So I need a list of 31 different slips essentially.
The problem is, my output keeps doing the same slip every day for 31 days because I know it's working off the attributes of one employee. I believe my problem is in my Employee constructor, considering this would only randomize the values once upon object intialization. I need it to randomize ONE employee's attributes for each node in the singly linked list.
You design is wrong. Line 11 should be moved to the Slip class. The Employee needs an array of 5 slips and a count for the available slips.
The class Slip shouldn't know anything about Employee. So move most if not all functions to Employee.
The constructs should initialize the members not much more. So I would suggest that you move the generation of the random data to main.
So:
1 2 3 4 5 6 7 8 9 10 11
class Slip {
private:
int prodID = 0, prodCost = 0, total = 0; // total must be calculated by Employee
...
class Employee {
private:
Slip slip_array[5];
int NUMSLIPS = 0;
I have since figured out my problem. Sometimes, I have a hard time viewing classes and objects as actual datatypes. I was trying to integrate a singly-linked list into my SalesPerson class rather than using Node class and List class as templated classes that simply form the architecture, if you will, of a singly-linked list. I then passed objects of types SalesPerson into the templated list. Thank you for you help though!