public class MasterOrder { /** The list of all cookie orders */ private List orders; /** Constructs a new MasterOrder object. */ public MasterOrder() { orders = new ArrayList(); } /** Adds theOrder to the master order. * @param theOrder the cookie order to add to the master order */ public void addOrder(CookieOrder theOrder) { orders.add(theOrder); } /** @return the sum of the number of boxes of all of the cookie orders */ public int getTotalBoxes() { /* to be implemented in part (a) */ } /** Removes all cookie orders from the master order that have the same variety of * cookie as cookieVar and returns the total number of boxes that were removed. * @param cookieVar the variety of cookies to remove from the master order * @return the total number of boxes of cookieVar in the cookie orders removed */ public int removeVariety(String cookieVar) { /* to be implemented in part (b) */ } public static void main(String[] args) { MasterOrder goodies = new MasterOrder(); goodies.addOrder(new CookieOrder("Chocolate Chip", 1)); goodies.addOrder(new CookieOrder("Shortbread", 5)); goodies.addOrder(new CookieOrder("Macaroon", 2)); goodies.addOrder(new CookieOrder("Chocolate Chip", 3)); int total = goodies.removeVariety("Chocolate Chip"); System.out.println("expected 4 and got " + total); total = goodies.removeVariety("Brownie"); System.out.println("expected 0 and got " + total); System.out.println("The current size of the master order should be 2 and we got " + goodies.orders.size()); } }