Girl Scout Cookie Order

We have all been there, the irresistible face of a cute kid selling tasty cookies.

They're everywhere...at the store, knocking on the door, in the parking lot...

Your objective is to create a console application that keeps track of the variety of cookie you ordered and the quantity using an Array. You will also keep track of your total number of boxes purchased. You are going to give the program the ability to remove a variety from the list, just remember, this may make the girl scout sad so please be kind!

The Order Object

  • Write this class to keep track of 2 pieces of instance data: variety of cookie and numBoxes purchased
  • Create the constructor to handle this data

Design Thinking: Why should we being using Constructor Injection as opposed to Field or Setter Injection?

The OrderList Class

  • Declare your const orders Array.
  • Create a constructor and consider what it may need (Think Dependency Injection)

OrderList should contain the following methods:

  • Proper Accessor Methods
  • addOrder(order)
  • getTotalBoxes()
  • removeOrdersByVariety(variety) (Should remove all orders with provided variety)
  • getBoxesByVariety(variety)

Design Thinking: Why did we have the OrderList Object choose to create the addOrder method rather than just exposing the Array and allowing external code to call the built in .push() method on it?

The Application Class

  • Keep ALL I/O here, but no logic.
  • Game Loop
  • Add 4 initial orders
  • Total the boxes purchased
  • Show the list
  • Remove a variety and give feedback on how many boxes were removed
  • Show the updated list

Example

Current Order
Variety: Tagalongs Boxes: 1
Variety: Thin Mints Boxes: 5
Variety: Samoas Boxes: 2
Variety: Tagalongs Boxes: 3

You have ordered 11 boxes

What would you like to remove? (specify a variety or none)
Thin Mints
You are removing 5 Thin Mints
Current Order
Variety: Tagalongs Boxes: 1
Variety: Samoas Boxes: 2
Variety: Tagalongs Boxes: 3

Stretch Task

  • Update to use an Object instead of an Array to identify specific Orders and interact with them individually.