Question: import java.util.*; public class TallyCounter { // PLEASE START YOUR CODE HERE // ********************************************************* protected int count; //counter /** This is the only constructor for



import java.util.*;
public class TallyCounter {
// PLEASE START YOUR CODE HERE
// *********************************************************
protected int count; //counter
/**
This is the only constructor for this class. This constructor
initializes the TallyCounter and sets its counter to 0.
parameter: counter: totally tally count (initially set to 0)
*/
public TallyCounter()
{
count = 0;
}
public void increment()
{
count++;
}
public int get()
{
return count;
}
// *********************************************************
// PLEASE END YOUR CODE HERE
}
import java.util.*;
public class PoD
{
public static void main (String [] arg )
{
Scanner in = new Scanner( System.in );
String nextTask;
ResetTally tally = new ResetTally();
while (in.hasNext())
{
nextTask = in.next();
if (nextTask.equals("increment"))
{
tally.increment();
}
else if (nextTask.equals("get"))
{
System.out.println(tally.get());
}
else if (nextTask.equals("reset"))
{
tally.reset();
}
}
System.out.print("END OF OUTPUT");
in.close();
}
}
Instructions The Museum of Natural History also has a visiting exhibit which can only hold a maximum number of people. They cycle guests in and out of this exhibit. As such we need our tally counter to be able to be reset back to zero You will subclass the TallyCounter class and implement a new tally counter called ResetTally which can be reset to zero. Details for this class are given below. Recall: The TallyCounter keeps track of the count. A TallyCounter has two methods: the increment) method and the get () method. These methods do the following increment) This method increases the total count by one. This method is used when a new visitor comes to visit Gus. One more visitor, one more push of the TallyCounter button to increment the count by one. . get This method returns an integer count of the number of visitors that have been by to see Gus so far
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
