In this lab you will practice using JUnit to test Java classes.
Your task is to write JUnit tests to test the Date class, which represents a calendar date. You should add your tests to the DateTest class. The class already contains one test object (accessed using the aDate field) and several test methods.
Your goal is to find TWO bugs in the Date class.
The Date class supports the following methods:
Constructor: public Date(int day, int month, int year)
The constructor initializes a Date object to a particular day, month, and year.
Instance method: public int getDay()
Returns the day of the month represented by a Date object.
Instance method: public int getMonth()
Returns the month (1 for January, 2 for February, etc...) represented by a Date object.
Instance method: public int getYear()
Returns the year represented by a Date object.
Instance method: public String getNameOfMonth()
Returns the name of the month represented by a Date object as a String ("January", "February", etc...)
Static method: public static boolean isLeapYear(int year)
Given a particular year as a parameter, returns true if the year is a leap year and false if the year is not a leap year.
The rule for leap years is:
If a year is evenly divisble by 4, and either
- it is NOT evenly divisible by 100, OR
- it IS evenly divisible by 400
then it is a leap year.
2007 is NOT a leap year (not divisible by 4)
2008 is a leap year (divisible by 4, and not divisible by 100)
1900 is NOT a leap year (divisible by 100 and not divisble by 400)
2000 is a leap year (divisible by 400)