Desparate for help

I have no idea how to add a new inventory bin to this program. I have been looking everywhere to try an figure it out but have come across nothing helpful. I appreciate any help. I could only post a portion of the code because the whole thing is too long. this is the part where i need to add the code for the newInventoryBin function

//____________________________________________________________________________
// Function: newInventoryBin -- Add a new Inventory bin to the array
//
// Inputs: parts = array of type InventoryBin
// activeBins = number of elements in 'parts' array which are
// actually in use.
// array_size = maximum number of elements in 'parts' array.
//
// Returns: SUCCESS if the new addition worked.
// FAILURE if there was not enough space in the 'parts' array.
//
// PostCondition: If there was space in the 'parts' array,
// then the 'parts' array contains the new data,
// and the 'activeBins' parameter has been incremented.
// The caller's variable corresponding to 'activeBins'
// will reflect the change, because 'activeBins' is
// "passed by reference".)
//
// Description: The 'newInventoryBin' function first checks if there is
// any space available in the 'parts' array.
// If not, the function returns a FAILURE status.
// If there is space, then 'newInventoryBin' prompts the user
// to input a description of what the new bin will contain, and
// what INITIAL quantity of items should be added to the new bin.
// If the user specifies an invalid initial quantity, then
// 'newInventoryBin' asks the user to enter a valid value.
// (An INVALID quantity value is one which is either
// less than zero, or greater than MAX_PARTS_PER_BIN.)
//
// Next, 'newInventoryBin' places the new data from the user
// into the next available array element in the 'parts' array.
// (This is the element at index 'activeBins'.)
// Lastly, 'newInventoryBin' increments the 'activeBins'
// and sets the return status to SUCCESS.
//

int newInventoryBin(InventoryBin parts[], int& activeBins, int array_size) {
int status = FAILURE;
InventoryBin dataValue;
int initialQuantity = 0;

// ADD YOUR CODE HERE.
if (MAX_PARTS_PER_BIN >= 30){
cout << " ";

}

return status;
} // (end function 'newInventoryBin')
Why don't you ignore, for the time being, the PostCondition. Focus on the description.

Step 1.
The 'newInventoryBin' function first checks if there is any space available in the 'parts' array.

How do you make this check?

Step 2.
If not, the function returns a FAILURE status.
There is one of your returns

Step 3.
If there is space, then 'newInventoryBin' prompts the user to input a description of what the new bin will contain, and what INITIAL quantity of items should be added to the new bin.

This is the else from step 2. How do you prompt the user and get the user's response? What data types are required for the description and INITIAL quantity?

Why don't you start with those steps. At the end, print out the description and INITIAL quantity to verify that you have the values you expect. When you get that, try to work on the next steps. When you get stuck again, post your code and ask more questions.
Last edited on
thanks Doug,

I know what I have to do, but I don't know how to do it, that is why I am here. My programming professor is god-awful and I have no idea how to check an array or return a failure status.
You posted this:
I have no idea how to check an array


You also posted this.
1
2
3
4
5
// Inputs: parts = array of type InventoryBin
// activeBins = number of elements in 'parts' array which are
// actually in use.
// array_size = maximum number of elements in 'parts' array.
// 


Now, how would you check to see if there is still space available in the 'parts' array?



You posted this:
or return a failure status


You also posted this function (I removed the stuff that is not important for this discussion):
1
2
3
4
5
int newInventoryBin(InventoryBin parts[], int& activeBins, int array_size) {
int status = FAILURE;
    ... (I removed extraneous lines here)
return status;
} // (end function 'newInventoryBin')  


Your professor already showed you how to return a failure status.

I'm not going to do your homework for you. I gave you a strategy for solving the problem. Contrary to your disparaging remarks, your professor did a really good job of describing the data you are receiving and the steps you need to implement. Now it's time for you to put some effort into reading the assignment and trying to work on a solution. If there is something you don't understand, ask a specific question. "I don't know how to do anything" doesn't cut it. A question like "If I compare activeBins with array_size, will that tell me if there is space available?" is much better. And better yet, typing up a question like that might help you answer the question for yourself.

If you don't understand the syntax required for writing your code, I suspect it's because you didn't read your textbook and didn't pay attention to your professor's lectures. I would recommend some of the tutorials on this web site. Topics that seem to me like they might be important are:

Control structures: http://www.cplusplus.com/doc/tutorial/control/
Functions: http://www.cplusplus.com/doc/tutorial/functions/
Arrays: http://www.cplusplus.com/doc/tutorial/arrays/
Basic Input and Output: http://www.cplusplus.com/doc/tutorial/basic_io/

A lot of people on this forum (including me) love to answer questions that beginners have. But we like to see effort first. When you bring us your attempt and ask questions about why it's not working, you will get great answers. When you tell us that your professor is terrible and you have no interest in trying to understand your assignment, the answers your receive will be fewer and less helpful.
Topic archived. No new replies allowed.