Dates and Times
The presidents.tsv file includes fields with the first inauguration and end of term dates for each president (end of term is empty for the current president).
- Modify the
Presidentclass to includeStringfields for the term begin and end dates. - Create getters and setters.
- Modify (or re-create) the constructor to include these new fields.
-
Add the new fields to
toString -
Copy
PresidentApp.java, naming the new copyPresidentAppDates. -
Make sure the new class's
maininstantiates aPresidentAppDates, notPresidentApp. - Modify
PresidentAppDatesto capture these fields from the file, and pass them to thePresidentconstructor. -
Get this working and tested, printing out the full list of presidents.
-
In the
Presidentclass, change the datatypes of the term begin and end dates toLocalDate. -
Fix the getters, setters, and constructor.
-
In
PresidentAppmodifyloadPresidentsto convert the date strings from the file toLocalDatevalues using aDateTimeFormatter. -
Add a new method to
President:getTermLength. This should return aPeriodobject representing the interval between the term begin and end dates. If the president has no term end date (that is, the current president) it should return the difference between term start and the current date. -
Include this in the president's
toString.
Stretch Goals¶
-
Create a method that takes a list of presidents and writes it as tab-separated values to a file.
-
Records should be formatted so the existing code would be able to read and parse the records.
-
When testing, be careful NOT to use resources/presidents.tsv as the output file!