Question: I want you to write a code in java. Suppose that there is a big farm in California that supplies the majority of the Grocery

 I want you to write a code in java. Suppose thatthere is a big farm in California that supplies the majority of

I want you to write a code in java.

Suppose that there is a big farm in California that supplies the majority of the Grocery stores in the twin cities with vegetables and fruits. The stores submit their orders and receive the shipment a week later. Based on the size of the orders, the farm management decides on the size of the truck to load Create a Produce class that have an instance variable of type String for the name, appropriate constructors, appropriate accessor and mutator methods, and a public toString0 method. Then create a Fruit and a Vegetable class that are derived from Produce. These classes should have constructors that take the name as a String and invoke the appropriate constructor from the base class to set the name. Also, they should override toString method to display the name of the produce and its type. For instance, Mango is a Fruit and Cauliflower is a Vegetable Finally, create a class called TruckOfProduce that will keep track of the boxes of Vegetables and Fruits added in to the truck. This class should use an and fruits. Also, it should have the following: array of Produce to store both vegetables Constructor that accepts an integer to initialize the array of Produce addProduce method that adds either fruit or vegetable to the array search method that accepts a name string, which can be either the name of a fruit or vegetable, and returns true if the name exists. Otherwise, it returns false remove method that accepts a produce object and returns true if the produce is found and removed successfully. Otherwise, it returns false toString method that returns all the produce from in the truck. ensureCapacity method this is a void method. When this method is called it will double the size of the array and copy all the content of the smaller array in to this bigger array For instance, one could initialize the array What will happen if you try to add one more box (1001)? Of course, you will get an ArrayIndexOutOfBound error. So, thing about ensureCapacity as the method that will solve ArrayIndexOutBound error to hold 1000 boxes of vegetables and fruits What to turn in: This time you have to turn in the whole project in a zip format. . First create a project and call it pa3 . Add a package; call the package edu.century.pa3 Add the Driver, Produce, Vegetable, Fruit, and TruckOfProduce to edu.century.pa3 package After you are done. Right click on the project name pa3 and generate a zip file. Call the zip file pa3.zip. . You turn in the pa3.zip

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!