Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

ArrayList Shopping cart

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. The purchase method must have furniture AND quantity.
. Number of furniture should not exceed the quantity in stock.
. Add the number of furniture to the purchase ArrayList
. Delete the same number of the furniture from the inventory

I tried this but doesn't work:

 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Please UseCodeTags (← click) when posting code as it makes it easier for people to read your code. I've added them for you this time.

To get the quickest and best responses to a question you need to TellTheDetails (← click), ie does it fail to compile (if so post the compiler message), throw an exception when running (if so post the exception message and stack trace) or just not give the required output (if so tell us what you expected and what it actually did)?

From a quick look at your code I can see it won't compile because the ArrayList class doesn't have a quantityInStock field. Ask yourself if you think it is correct to be looking at the list of items to purchase for the quantity in stock or should this be a field in the Inventory class.
 
reply
    Bookmark Topic Watch Topic
  • New Topic