Adapt Scanner to the PersonScanner interface.
The adapter class is PersonScannerAdapter.
Create a private final Scanner field called fileScanner in the adapter class. Initialize the field in a constructor with one Scanner parameter.
The file stores data in the following format:
John Michael Peterson
Yet another adapter
- 20
Locked
Comments (7)
- Popular
- New
- Old
You must be signed in to leave a comment
Mike S
23 February, 15:29
As usual, make sure to trim your strings before entering them as arguments for the Person constructor! : )
0
Олег БайбулаExpert
3 March, 11:35
Why do you need trim here?
0
Mike S
6 March, 17:08
Well, usually, the validator doesn't like those extra trailing spaces at the end of the output. Who knows, maybe it tolerates them here?
0
Jurij Thmsn
17 April 2021, 15:07
First Name: John
Middle Name: Michael
Last Name: Peterson
+1
Bartlomiej Drozd
1 March 2021, 19:05
The requirement here is misleading. You are not supposed to read a file at all. Otherwise, you won't be able to apply "final" modifier to Scanner.
+1
Guadalupe Gagnon
27 September 2021, 13:39
"You are not supposed to read a file at all" - correct.
Where is it misleading and saying to read a file? It specifically says to initialize the Scanner through the constructor, which is perfectly normal.
0
Justin Smith
12 October 2021, 00:47
I would just say it's easy to misunderstand.
0