Question: Need to complete all //TO DO comments in the following class (java code): public class Trove implements Treasure { // TODO instance variables with documentation

Need to complete all //TO DO comments in the following class (java code):

public class Trove implements Treasure { // TODO instance variables with documentation comments /** * Constructs a new Trove with the Treasure objects specified by * contents. * * @param contents * The Treasures to store in this Trove. Must not be null * nor contain null. The caller of the constructor is allowed * to make changes to the parameter array after the constructor * call, and this Trove object (and its internal representation) * will not be affected by this. */ public Trove(Treasure[] contents) { // TODO } /** * Returns the sum of the values of the component Treasures. * * @return the sum of the values of the component Treasures */ @Override public long getValue() { return 0; // TODO } @Override public String toString() { return null; // TODO } }

The implemented class:

public interface Treasure { /** * Returns the value of the Treasure. Note that the value of a Treasure * can be positive, zero, or negative. * * @return the value of the Treasure */ long getValue(); }

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!