John Johnson

  • 20
  • Locked
The first parameter of the main method is a file name. Each line of the specified file has the following format: name month day year where [name] is a String that can contain several words separated by spaces. [month] is an int, [day] is an int, and [year] is an int. The data is separated by spaces.
You can't complete this task, because you're not signed in.
Comments (3)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Олег Байбула
Level 32 , Ukraine
6 March, 09:01
Why can't I use deprecated Date constructor?
    public Date(int year, int month, int date) {
        this(year, month, date, 0, 0, 0);
Adam Odoj
Level 22 , Poland
1 February, 11:33
My solution was accepted and is even shorter then proposed. I just find how to create Person on the same moment that the file is read. You dont need even the bufferedReader but just read int after int converted to char with only 2 "if's". Important to check is if character isDigit() and the char before space was digit or letter. You will build 2 strings: with name and with date in String. Then when line came to the end or file is end (if ( !fr.ready() || i ==10) parse date, add new person then reset string with name and date and continue reading. Last hard tasks was taking me to resolve days, but this one I get in half an hour. This time I'm proud and going for next...
15 August 2020, 20:55
You might want to explore Builder Design pattern as well for building Person objects using unstructured data. I found this video helpful Builder Design Pattern Example