Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Directions: SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. . Notes Assume that the classes listed in the Quick

image text in transcribed
image text in transcribed
image text in transcribed
Directions: SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. . Notes Assume that the classes listed in the Quick Reference found in the Appendix have been imported where appropriate Unless otherwise noted in the question, assume that parameters in method calls are not null and that methods are called only when their preconditions are satisfied In writing solutions for each question, you may use any of the accessible methods that are listed in classes defined in that question. Writing significant amounts of code that can be replaced by a call to one of these methods may not receive full credit. 1. An organization raises money by selling boxes of cookies. A cookie order specifies the variety of cookie and the number of boxes ordered. The declaration of the CookieOrder class is shown below. public class cookieOrder public /** Constructs a new cookieOrder object. :/ public CookieOrder (String variety, int numBoxes) { /* implementation not shown */ } /** @return the variety of cookie being ordered */ public String getVariety { /* implementation not shown */ } /* @return the number of boxes being ordered public int getNumBoxes { /* implementation not shown */ } // There may be instance variables, constructors, and methods that are not shown. 3 The Masterorder class maintains a list of the cookies to be purchased. The declaration of the Masterorder class is shown below. public 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) Torders.add(theOrder); } /** @return the sum of the mumber of boxes of all of the cookie orders public int get TotalBoxes ( { /* 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. aparam 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) */ } + // There may be instance variables, constructors, and methods that are not shown. } 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) */ } // There may be instance variables, constructors, and methods that are not shown. 3 (a) The getTotalBoxes method computes and returns the sum of the number of boxes of all cookie orders. If there are no cookie orders in the master order, the method returns 0. Complete method getTotalBoxes below. /** @return the sum of the mumber of boxes of all of the cookie orders */ public int get TotalBoxes ()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions