Please include all classes including driver.
IN JAVA
Suppose that there is a big farm in California that supplies themajority of the Grocery stores in the twin cities with vegetablesand fruits. The stores submit their orders and receive the shipmenta week later. Based on the size of the orders, the farm managementdecides on the size of the truck to load.
Create a Produce class that have an instance variable of typeString for the name, appropriate constructors, appropriate accessorand mutator methods, and a public toString() method. Then create aFruit and a Vegetable class that are derived from Produce. Theseclasses should have constructors that take the name as a String,the price (this is the price per box) as a double, the quantity asan integer, and invoke the appropriate constructor from the baseclass to set the name. Also, they should override toString methodto display the name of the produce, the price, and its type. Forinstance, Mango is a Fruit and Cauliflower is a Vegetable.
Finally, create a class called TruckOfProduce that will keeptrack of the boxes of Vegetables and Fruits added in to the truck.This class should use an array of Produce to store both vegetablesand fruits. Also, it should have the following:
• Constructor that accepts an integer to initialize the array ofProduce
• addProduce method that adds either fruit or vegetable to thearray
• search method that accepts a name string, which can be eitherthe name of a fruit or vegetable, and returns true if the nameexists. Otherwise, it returns false.
• remove method that accepts a produce object and returns trueif the produce is found and removed successfully. Otherwise, itreturns false.
• computeTotal method that will return the total cost of all theproduce in the truck.
• toString method that returns all the produce from in thetruck.
• ensureCapacity method this is a void method. When this methodis called it will double the size of the array and copy all thecontent of the smaller array in to this bigger array.
For instance, one could initialize the array to hold 1000 boxesof vegetables and fruits. What will happen if you try to add onemore box (1001)? Of course, you will get an ArrayIndexOutOfBounderror. So, thing about ensureCapacity as the method that will solveArrayIndexOutBound error.
Then wrap it up with the driver class that tests all methods anddisplays the name of the produce, the price, and its type.