Question: WrapWagon Submit a compressed file (either .zip or .jar) containing both .java class files. You have been hired by Wonda's Wrap Wagon, a food truck,

WrapWagon

Submit a compressed file (either .zip or .jar) containing both .java class files.

You have been hired by Wonda's Wrap Wagon, a food truck, to write a program that processes customer orders, maintaining a record of inventory items and total sales. Your code will report this information on request and will update the totals as orders are processed.

Objectives

Write code consisting of a supplier class and a client class.

Ensuring code works to specification.

Specification

Wonda's Wrap Wagon sells four (4) menu items, but also has two (2) special combinations. The shop offers a 10% discount on combos. Here's a summary:

a singleTurkey

for $ 6.95 each,

using 1 serving of turkey,

1 wrap and 1 paper holderall from stock

a doubleTurkey

for $ 8.75 each,

using 2 servings of turkey,

1 wrap and 1 paper holderall from stock

a cheeseTurkey

for $ 7.50 each,

using 1 serving of turkey, 1 slice of cheese, 1 wrapand 1 paper holder all from stock

a soda

for $ 1.50 each, using 8 oz of soda, and 1 cup from stock

Combo #1 consists of

1 singleTurkey

1 soda

Combo #2 consists of

1 cheeseTurkey

2 sodas

Your code will consist of 2 classes: the first is a supplier class called Order that contains all the information about an order to be placed at the burger stand. An order needs to know exactly how many of each base product (from the 4 listed in the top row of the table above) make up this Order. It also needs to know if the Order was made up of combos. Like a String, an Order is immutable.

Class Order

+ Order() -- constructs a new Order for Combo #1 + Order( int combo1Count, int combo2Count ) -- constructs a new Order with the specified number of combos. + Order( int singleTurkeyCount, int doubleTurkeyCount, int cheeseTurkeyCount,int sodaCount ) --constructs a new Order with the specified number of items. Note: an Order made with this constructor is not a combo, even if the items in the Order are the same as a combo.

Make sure to test for and document preconditions.

+ int getSingleTurkeyCount() + int getDoubleTurkeyCount() + int getCheeseTurkeyCount() + int getSodaCount() +boolean isCombo()

A client class called WrapWagon maintains important information about the food truck, including

an inventory of critical items (found in blue in the table above)

a record of total sales: the total amount of money the food truck has taken in

the average cost of an Order, based on all the Orders placed

Class WrapWagon

+ WrapWagon() -- constructs a WrapWagon that has 1500 servings of turkey, 1000 wraps, 1000 paper holders, 800 slices of cheese, 600 ounces of soda, 75 cups in inventory. No sales have been made yet.

+ double getTotalSales() + double getAveCost() - return the average cost per Order.

// These return the current state of inventory for each item + int getTurkeyCount() + int getWrapCount() + int getHolderCount() + int getCheeseCount() + int getSodaCount() + int getCupCount()

+ String toString() -- create a String that represents the current state of this WrapWagon.

+ double processOrder( Order theOrder ) -- process the given Order: meaning update the state of this WrapWagon. Return the price for theOrder. (Return value is not the same as getTotalSales()) This method should also do precondition testing: if it can't fill theOrder, it should throw an exception and not update the state.

Additional Requirement: Both Order and WrapWagon classes should include a static test method. Within this method, you should write code to test your classes.

NOTE: in this homework, you are not writing a complete program. You are just defining two new classes: one is a client of the other. Realize that both of these classes would then be clients in some larger program. You'll come to realize that the code for this assignment is pretty simple; none of these methods have very complex algorithms. The work is getting comfortable with defining objects and easily moving back and forth between client and supplier perspectives.

Documentation

From this homework forward, you must use Javadoc comments for each class definition and before each method definition. Use @author, @param, @throws and @return tags where appropriate. Refer to the supplemental reading for more info.

Include internal comments and class constants where appropriate.

Make sure to test your public documentation by creating the JavaDocs and reviewing the webpages. Make sure each javadoc tag is working.

Be sure to use descriptive names for variables and constants.

Suggestions

Develop the supplier class ( Order ) first and test it thoroughly using BlueJ's object bench or code pad. Once this is is working...

Develop the client class, then test it by creating several orders and "process" them at the wrap wagon. Put your test code in a static test() method of the WrapWagon class. This method should create several different types of Orders, process them with the WrapWagon object, and then display some results.

Determine in advance (by hand) how each order should impact the WrapWagon and make sure that everything is working properly.

Grading

/5 Order class /10 WrapWagon class /5 Documentation and style Good Luck!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!