Question: Goal: In this problem, you will revisit Tree and Orchard classes from Homework 1 2 Problem 1 2 B and implement a few updates as

Goal:
In this problem, you will revisit Tree and Orchard classes from Homework 12 Problem 12B and
implement a few updates as follows:
The Height parameter in the Tree class is now an int instead of a double.
The Tree class implements the Comparable interface a tree comes first if its short, or its type
is smaller when its height is the same as another tree.
The Orchard class uses an array instead of an ArrayList to keep track of Tree objects.
Instructions:
Start a new BlueJ project called hw14c in the cs46a/homework/hw14 folder. In the BlueJ project, create
a class called OrchardTester and copy over the code provided on Canvas. Next, create two classes
called Orchard and Tree (the starter code provided for this example is the code you wrote from
Homework 10).
Modify the Tree and Orchard classes using the updates listed above.
The Orchard should have the following methods:
add()
Adds a tree at a given position of the array if the array is not full and the index is valid. It
does not do anything otherwise.
lastTallTree()
Returns the last tree with a height at of at least 30 or null if there is no such tree. The
method should stop execution and return the last tall tree after it is found.
contains()
Determine if the array contains a Tree object of a given type. It returns either true or false.
treeList()
Returns an ArrayList containing the types of all Tree objects in the array.
sort()
Sort the array by calling a static method of class Arrays.
In addition, add an argument to the Orchard constructor to ingest the size of the array.
Tips and Guidelines:
Call the static method to sort.
Observe the behavior of the OrchardTester script to determine the action of the Tree and
Orchard classes.

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!