Question: Create an application to manage a fresh produce store. Define at least 4 classes that implement Produce (attached), such as Potato, Asparagus, etc. Each of

Create an application to manage a fresh produce store.

Define at least 4 classes that implement Produce (attached), such as Potato, Asparagus, etc. Each of these should represent a type of produce, with a name, a weight, and a price per pound. All but the weight should be hard-coded in the default constructor. For the weight, hard code a range of pounds for the produce, such as, for example, .5 to 1.5 for a Potato. Note that that can also be described a random number from 0 to 1.0 plus .5. In addition to the Interface methods and a constructor, each should also override the toString() method to return a string such as the following for a Potato: Idaho potato, 1.2 lbs. at $.60 per pound: $.73 Idaho potato, .7 lbs. at $.60 per pound: $.44

Also define a Driver which will print a menu of produce types, plus an option to check out, get the user's choice, prompt the user for a quantity, then add that many new instances of the chosen class of Produce to an ArrayList. When the option to check out is selected, the Produce should be printed out one at a time, followed by the total price, formatted as currency.

Produce:

public interface Produce { public double getWeight(); public double getPricePerPound(); public double getPrice(); }

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!