Advertisement
ralumysterious

challenge

Nov 21st, 2019
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. Modify the program so that adding items to the shopping basket doesn't actually reduce the stock count but, instead, reserves the requested number of items.
  2.  
  3. You will need to add a "reserved" field to the StockItem class to store the number of items reserved.
  4.  
  5. Items can continue to be added to the basket, but it should not be possible to reserve more than the available stock of any item. An item's available stock is the stock count less the reserved amount.
  6.  
  7. The stock count for each item is reduced when a basket is checked out, at which point all reserved items in the basket have their actual stock count reduced.
  8.  
  9. Once checkout is complete, the contents of the basket are cleared.
  10. It should also be possible to "unreserve" items that were added to the basket by mistake.
  11.  
  12. The program should prevent any attempt to unreserve more items than were reserved for a basket.
  13.  
  14. Add code to Main that will unreserve items after they have been added to the basket, as well as unreserving items that have not been added to make sure that the code can cope with invalid requests like that.
  15.  
  16. After checking out the baskets, display the full stock list and the contents of each basket that you created.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement