Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need to fill in the //TO DO comments for the following java class: Coin.java public class Coin extends SimpleTreasure implements HasName { // TODO
I need to fill in the //TO DO comments for the following java class:
Coin.java
public class Coin extends SimpleTreasure implements HasName { // TODO instance variables with documentation comments /** * Constructs a new Coin with specified value and name. * * @param value * The value of the Coin. * @param name * The name of the Coin. Must not be null. */ public Coin(long value, String name) { super(value); // TODO } @Override public String getName() { return null; // TODO } @Override public String toString() { return null; // TODO } }
Other dependent classes:
SimpleTreasure.java
public class SimpleTreasure implements Treasure { // declaring instance variables private final long value; /** * Constructs a new SimpleTreasure with the specified value. * * @param value * The value to assign to the SimpleTreasure. */ public SimpleTreasure(long value) { this.value = value; } @Override public long getValue() { return value; } @Override public String toString() { return "Treasure value is:" + getValue(); } }
HasName.java
public interface HasName { /** * Returns the name associated with the object. * * @return the name associated with the object */ String getName(); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started