Any idea how to fix my solution?
package pl.codegym.task.task19.task1904;
import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
/*
Jeszcze jeden adapter
*/
public class Solution {
public static void main(String[] args) {
}
public static class PersonScannerAdapter implements PersonScanner {
private Scanner fileScanner;
public PersonScannerAdapter(Scanner fileScanner) {
this.fileScanner = fileScanner;
}
@Override
public Person read() throws IOException {
Person person = null;
if (fileScanner.hasNext()) {
String line = fileScanner.nextLine();
String[] arr = line.split(" ");
String lastName = arr[0];
String firstName = arr[1];
String middleName = arr[2];
String birthMonth = arr[3];
String birthDay = arr[4];
String birthYear = arr[5];
DateFormat df = new SimpleDateFormat("MM DD YYYY");
Date birthday = null;
try {
birthday = df.parse(birthMonth + " " + birthDay + " " + birthYear);
}
catch (ParseException e) {
}
person = new Person(lastName, firstName, middleName, birthday);
}
return person;
}
@Override
public void close() throws IOException {
fileScanner.close();
}
}
}
/*Jeszcze jeden adapter
Dostosuj Scanner do interfejsu PersonScanner.
Klasa adaptera to PersonScannerAdapter.
Utwórz prywatne pole final Scanner o nazwie fileScanner w klasie adaptera.
Inicjalizuj pole w konstruktorze z jednym parametrem Scanner.
Plik przechowuje dane w następującym formacie:
John Michael Peterson 12 31 1950
Larry Thomas Gates 12 31 1957
Plik zawiera informacje o wielu osobach. W każdej linii znajdują się dane dotyczące jednej osoby. Metoda read() musi odczytywać informacje dotyczące tylko jednej osoby.
Requirements:
1. PersonScanner musi być interfejsem.
2. Klasa PersonScannerAdapter musi implementować interfejs PersonScanner.
3. Klasa PersonScannerAdapter musi posiadać prywatne pole Scanner o nazwie fileScanner.
4. Klasa PersonScannerAdapter musi posiadać konstruktor z parametrem Scanner.
5. Metoda close() klasy PersonScannerAdapter musi delegować wywołanie do fileScanner.
6. Metoda read() klasy PersonScannerAdapter powinna odczytywać linię z pliku, parsować ją i zwracać dane tylko jednej osoby jako obiekt Person.*/