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 a List
. 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
Class
- Write this class to keep track of 2 pieces of instance data:
variety
of cookie andnumBoxes
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 OrdersMasterList
Class
- Declare your
private List<Order>
and name itorders
- Create a constructor and consider what it may need (Think Dependency Injection)
OrdersMasterList
should contain the following methods:
- Proper Accessor Methods
public void addOrder(Order orderToAdd)
public int getTotalBoxes()
public void removeVariety(string variety)
(Should remove all orders with provided variety)public int getVarietyBoxes(string variety)
Design Thinking: Why did we have the OrdersMasterList
class choose to create the addOrder
method rather than just exposing the List<Order>
and allowing external code to call the built in add
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 the type of "
Collection
" you're using to identify specificOrder
s and interact with them individually.