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
Produce:
public interface Produce { public double getWeight(); public double getPricePerPound(); public double getPrice(); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started