Hi, I am an EXTREME beginner in C++ programming and I wish for some help on where to start for my code for my program assignment. I will post the code in another comment.
This is the assignment:
Using the variables created for the application, create a class object called Inventory. Our variables should be private within that class. In addition, set up public member functions for setting and getting the values for those private variables. There should be two constructors: a default constructor to set all values to zero or empty (for string variables), and a parameter constructor for setting the values when declared.
The class will also include functions for calculating the total value of the inventory and for generating the random number for the SKU.
This doesn't do what you want. It takes an unnamed and unused argument, then it does this->itemNumber = this->itemNumber, which does nothing. You want:
1 2 3 4
void setItemNumber(int n)
{
itemNumber = n;
}
You need to make similar changes to the other set() methods.
There's no need to store the totalCost. You should just compute the value in getTotalCost(). If you store it then you must update the value whenever the cost or quantity changes, which complicates the code.
Inside main(), I think you should just have the Inventory object and a temporary object for inputting the values.
Okay, that works great! Although there are a few things I wish to add/change within the code.
I believe a loop that asks the user for the category, the item, the price, and the number in stock can perhaps be added? So all that is required is the modifications in variables. That way the validation for the input is within the class.