Form a subclass StateQuarter from the class Coin. A state quarter has a state th
ID: 669950 • Letter: F
Question
Form a subclass StateQuarter from the class Coin. A state quarter has a state theme.
The toString method should yield a string such as
Use the following files:
Coin.java
QuarterTester.java
Complete the following file:
StateQuarter.java
(the . . . is where new code needs to go)
/**
A quarter with a state theme.
s*/
public class StateQuarter extends Coin
{
// your work here
/**
Constructs a state quarter.
@param aState the state name
*/
public StateQuarter(String aState)
{
super(0.25, "Quarter");
// your work here
}
/**
Gets the description of this object.
@return a description of this coin
*/
public String toString()
{
// your work here
}
}
Explanation / Answer
/**
A quarter with a state theme.
s*/
public class StateQuarter extends Coin
{
String stateName;
/**
Constructs a state quarter.
@param aState the state name
*/
public StateQuarter(String aState)
{
super(0.25, "Quarter");
stateName=aState;
}
/**
Gets the description of this object.
@return a description of this coin
*/
public String toString()
{
return super.toString()+"[state="+stateName+"]";
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.