Question: Starting code is given for a class whose objects represent the current date as int month , int day , int year . Complete the
Starting code is given for a class whose objects represent the current date as int month, int day, int year. Complete the instance method public boolean isValid() which should return true if the current fields represent a valid date. This method is used in the GPSDate constructor to check that the initializing date is valid.
Work on completing this by doing test-driven development, creating JUnit test methods within the JUnit test case GPSDateTest. First write a test method (preface header with @Test) that fails (try writing one that expects the date 0/1/2017 to be valid), then complete just enough code so the test succeeds (i.e. add a check for month <= 0). Then write another test that fails for the date 13/1/2017, and so forth.
Also continue to add to your JUnit test case GPSDateTest, striving to test all possible code paths in your method. As above, put all test code within a test source folder in Eclipse. Be sure you handle (and test for the correct handling of): invalid months, invalid days for the given month, including both leap and non-leap years, and invalid years (those part of dates before Oct 15, 1582).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
