Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create, test, and document a Java class using the adapter pattern to implement the following interface. *o A PushbackableTokenizer allows the user to read a
Create, test, and document a Java class using the adapter pattern to implement the following interface. *o A PushbackableTokenizer allows the user to read a token and push it back to the stream *from which the token was read. Tokens are assumed to be separated by white space. *Any number of tokens may be pushed back. *@author public interface PushbackableTokenizer i * Returns the next token * areturn the next token public String nextToken(); k * * Returns true if and only if there are more tokens @return true if there is at least one more token; else false public boolean hasMoreTokens(); * The last token read and is not pushed back * is pushed back, so it can be read again using nextToken. public void pus hback); Your task is to implement the above interface using the Adapter pattern. For this, use the StringTokenizer and Stack classes, You must also submit a driver program that creates an instance of the class and exercises all of its methods You can think of the tokens as of two types: . ones that have been supplied to the client reading the PushbackableTokenizer and were either not pushed back or were pushed back but then reread as many times as the number of pushbacks . ones that have been supplied to the client reading the Pushbackable Tokenizer and have been pushed back (perhaps multiple times), but have not been read back after the last pushback
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