Question: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Java!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Make Scanner class. you are to design, implement, document, and test a class that provides objects that have a subset of the capabilities of
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Java!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Make Scanner class.
you are to design, implement, document, and test a class that provides objects that have a subset of the capabilities of Scanners
-Provide a constructor that takes a String as a parameter
-Provide four methods: <
1.hasNext(), which takes no parameters and returns a boolean
2.next(), which takes no parameters and returns a String
3.hasNextInt(), which takes no parameters and returns a boolean
4.nextInt(), which takes no parameters and returns an int
!!!!Not use Scanner in its implementation!!!!!
A MyScanner should behave just like a Scanner would if you only used the Scanner's String constructor and its hasNext(), next(), hasNextInt(), and nextInt() methods. Be sure that you understand exactly how Scanners behave, including the circumstances in which exceptions are thrown. Don't simply assume you know how those methods interact.
For example, hasNextInt() doesn't report whether there is an integer token somewherein the Scanner; it reports whether the next token can be parsed as an int by Integer.parseInt(). You should read the relevant parts of the Scanner documentation (Links to an external site.)Links to an external site. and (probably more importantly) experiment with Scanners.
Since there is no close() method, none of the MyScanner methods should ever throw an IllegalStateException. However, in the right circumstances some of the MyScanner methods should throw a java.util.NoSuchElement exception and/or a java.util.InputMismatchException.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
