Question: In this test, we will look at a data structure for representing fruit trees in an orchard. The overal interface for these trees is here:

 In this test, we will look at a data structure for

In this test, we will look at a data structure for representing fruit trees in an orchard. The overal interface for these trees is here: interface Tree t int size0:I/ total number of fruit in the tree Tree grow(int factor); I/ grows the number of fruit by given factor void harvest (Collection bag): // harvests (adds) all fruits in this t a) 1 First, complete the following class for representing individual fruit in the tree. abstract class Fruit implements Tree t e0verride public int sizeO (// write this method below eoverride public Tree grow(final int factor) / TODO in 2d) below, not here /) e0verride public void harvest (final Collection bag) rite this method below We also need a few concrete kinds of fruit: class Mango extends Fruit / intentionally left empty/) class Peach extends Pruit / intentionally left empty b) 1 Next, complete the following class for building more complex trees from simpler ones. The class is continued on page 3. class Branch implements Tree f public Branch (final Tree... children) ( this. children - Arrays. asList (children): ) private final List children; public ListCTree getChi ldren 0 ( return children: ) eoverride public int sizeO // write this method below 00verride public Tree grow(final int factor) /TOD0 in 2d) belox, not here /1 eoverride public void harvest (final Collection Fruit) beg) (/ write this method below

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!