Inventory Stock Control
hardQuestion 591The Inventory class tracks a private field quantity that starts at 0. Add AddStock(int amount) that increases the quantity but ignores amounts of 0 or less, RemoveStock(int amount) that removes stock only when there is enough (returning true on success and false otherwise), and a read-only property Quantity. The tester prints the result of a removal, then the remaining quantity. Do NOT write a Main method.
After adding 10 and removing 4 the program prints the output shown in Expected Output.
If a removal is larger than the stock it is refused, so adding 5 then removing 9 prints: False 5
Expected output
True 6
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Encapsulation
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cw, cr, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.