Yet another adapter

  • 20
  • Locked
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
You can't complete this task, because you're not signed in.
Comments (7)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Mike S
Level 26 , Saint Louis, United States
23 February, 15:29
As usual, make sure to trim your strings before entering them as arguments for the Person constructor! : )
Олег Байбула
Level 32 , Ukraine
3 March, 11:35
Why do you need trim here?
Mike S
Level 26 , Saint Louis, United States
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?
Jurij Thmsn
Level 29 , Flensburg, Germany
17 April 2021, 15:07
First Name: John Middle Name: Michael Last Name: Peterson
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.
Guadalupe Gagnon
Level 37 , Tampa, United States
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.
Justin Smith
Level 38 , Greenfield, USA, United States
12 October 2021, 00:47
I would just say it's easy to misunderstand.