// Set the type of data stored in the box
typedefdouble ItemType;
// Declaration for the class PlainBox
class PlainBox
{
private:
// Data field
ItemType vStore[10];
int capacity;
int num_used;
int num;
public:
// Default constructor
PlainBox ();
// Parameterized constructor
PlainBox (const ItemType theItem);
// Method to change the value of the data fi eld
void setItem (const ItemType theIte);
// Method to get the value of the data fi eld
ItemType getItem () const;
}; // end PlainBox
#endif
lab1.cpp
--------
line 8: You initialize both num and num_used to 0. Not clear why you have two variables. You never change either of these variables.
Line 19: You always store the 0'th variable since you never incremented num.
Line 24: You always retrieve the 0'th variable since you never incremented num.
Suggestion: Get rid of num as a member variable. Pass num as an argument to get_item().
In setItem(), increment num_used.
edit: observations based on link in jlb's post:
1) Instructions do NOT say to create num as a member variable.
2) No where do you check if the array is full. The instructions say to provide a bool function to do this.
3) No function to determine if the array is empty.
4) No function to return the array capacity.
5) A getter with one argument. Your getter has no arguments.
6) A setter to overwrite a specific position. Not present.
7) A setter to add an element at the back. No correctly implemented.
8) A function to return the position of an element. Not present.
9) The driver should implement a menu system. Not present.
Part of the assignment requirement is to have a variable to hold the number of elements used.
Your class should include the following data members:
• An array (of size 10 by default)
• A variable to hold the array capacity (capacity).
• A variable to keep track of the number of elements currently being used (num_used).
Edit: As stated above you don't need num as a member variable.