public SpeedDating()
{
} // Constructor has empty body
/**
* Prints the day of the week (e.g. "Thursday") on which Halloween will
* fall for 10 consecutive years.
* @param startYear the first of the 10 consecutive years
*/
public void printHalloweens(int startYear)
{
// TO DO: write body of this method here
}
/**
* Computes and returns the Date on which Thanksgiving will fall
* in a given year.
*
* NOTE: By law, Thanksgiving is the 4th Thursday in November
*
* @param year the year for which to compute the date of Thanksgiving
* @return the Date of Thanksgiving for the specified year
*/
public Date getThanksgiving(int year)
{
// TO DO: write body of this method here
}
/**
* Computes and returns the number of days between two dates,
* counting the end date but not the start date. E.g., the
* number of days between 11/1/2012 and 11/5/2012 is 4, not 5.
*
* Precondition: The start date must occur on or before the end date.
*
* @param start the earlier of the two dates
* @param end the later of the two dates
*
* @return the number of days elapsed between the start date and the
* end date
*/
public int countingTheDays(Date start, Date end)
{
// TO DO: write body of this method here
}
}
This is the documentation
Constructor Summary
SpeedDating()
Creates an empty SpeedDating object so that you can call the methods (a constructor that takes no parameters is known as a "default" constructor)
Method Summary
int countingTheDays(Date start, Date end)
Computes and returns the number of days between two dates, counting the end date but not the start date.
Date getThanksgiving(int year)
Computes and returns the Date on which Thanksgiving will fall in a given year.
void printHalloweens(int startYear)
Prints the day of the week (e.g.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
SpeedDating
public SpeedDating()
Creates an empty SpeedDating object so that you can call the methods (a constructor that takes no parameters is known as a "default" constructor)
Method Detail
printHalloweens
public void printHalloweens(int startYear)
Prints the day of the week (e.g. "Thursday") on which Halloween will fall for 10 consecutive years.
Parameters:
startYear - the first of the 10 consecutive years
getThanksgiving
public Date getThanksgiving(int year)
Computes and returns the Date on which Thanksgiving will fall in a given year. NOTE: By law, Thanksgiving is the 4th Thursday in November
Parameters:
year - the year for which to compute the date of Thanksgiving
Returns:
the Date of Thanksgiving for the specified year
countingTheDays
public int countingTheDays(Date start,
Date end)
Computes and returns the number of days between two dates, counting the end date but not the start date. E.g., the number of days between 11/1/2012 and 11/5/2012 is 4, not 5. Precondition: The start date must occur on or before the end date.
Parameters:
start - the earlier of the two dates
end - the later of the two dates
Returns:
the number of days elapsed between the start date and the end date
1. Create a SpeedDating object
2. Have the user enter a year, and call the printHalloweens method to print the day of the week on which Halloween will occur for the next 10 years, starting with the input year
3. Have the user enter another year, call the getThanksgiving method, and print the Date object returned. Print the Date in the main method, not in SpeedDating.
4. Have the user enter another year, call getThanksgiving again, and print the Date object returned again.
5. Have the user enter the data for two Date objects - an earlier date and a later one. Create the two Date objects, call the countingTheDays method, and print the value returned.
Assume that the earlier date always occurs before the later one
I'm not asking for you to do my homework or anything just an explanation on what I have to do. The assignment specified that I just have to complete the method bodies and create a test class. To get credit for the methods I must use a loop. I don't understand why I would need a loop for the getThanksgiving one. I'm so confused. Someone please help me.