Question
Write a class in java that implemts this interface public interface LookupInterface { /** * Increase the count of string s. * * @param amount
Write a class in java that implemts this interface
public interface LookupInterface {
/**
* Increase the count of string s.
*
* @param amount Amount by which it is being increased.
* @param s String whose count is being increased.
*/
public void addString(int amount, String s);
/**
* Return the number of times string s has been seen.
* @param s The string we are counting.
* @return int The number of times s has been seen thus far.
*/
public int lookupCount(String s);
/**
* Get the nth most popular item based on its count. (0 = most popular, 1 = 2nd most popular).
* In case of a tie, return the string that comes first alphabetically.
* @param n Rank requested
* @return string nth most popular string.
*/
public String lookupPopularity(int n);
/**
* Return the total number of UNIQUE strings in the list. This will NOT be equal to the number of
* times increaseCount has been called, because sometimes you will add the same string to the
* data structure more than once. This function is useful when looping through the results
* using lookupPopularity. If you do lookupPopularity(numEntries()-1), it should get the least popular item.
* @return Number of distinct entries.
*/
public int numEntries();
};
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