/** * A class to give students experience using loops. This class * creates and manipulates objects of Greg's Date class. */ public class SpeedDating2 { // Note: this class has no instance variables! /** * Create an empty SpeedDating object * (this is known as a "default" constructor) */ public SpeedDating2() {} // 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 } /** * Prints the day of the week (e.g. "Thursday") on which the 4th of July * will fall in 10 consecutive years * @param startYear the first of the 10 consecutive years */ public void print4thOfJulys(int startYear) { // 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/2/2010 and 11/5/2010 is 3, not 4. * * 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 getDaysBetween(Date start, Date end) { // NOTE: Do NOT modify the parameters "start" or "end" in this method! // Doing so will modify the arguments in the calling method! // If you need to do this (most likely you will need to modify one), // use one of the copies provided here instead: Date d1 = new Date(start.getMonth(), start.getDay(), start.getYear()) ; Date d2 = new Date(end.getMonth(), end.getDay(), end.getYear()) ; // TO DO: write remainder of body of this method here } /** * Prints the day of the week (e.g. "Thursday") on which Valentine's * day will fall for 10 consecutive years * * Note: Valentine's Day is February 14th * * @param startYear the first of the 10 consecutive years */ public void beMyValentine(int startYear) { // TO DO: write body of this method here } /** * Computes and returns the Date on which Columbus Day will fall * in a given year. * * NOTE: By law, Columbus Day is the second Monday in October * * @param year the year for which to compute the date of Columbus Day * @return the date of Columbus Day for the specified year */ public Date discoverColumbusDay(int year) { // TO DO: write body of this method here } /** * Returns the date that lies midway between two dates. * * 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 Date halfway between the start date and the end date */ public Date getHalfWayDate(Date start, Date end) { // NOTE: Do NOT modify the parameters "start" or "end" in this method! // Doing so will modify the arguments in the calling method. // Instead, use one (or both) of the copies created below: Date d1 = new Date(start.getMonth(), start.getDay(), start.getYear()) ; Date d2 = new Date(end.getMonth(), end.getDay(), end.getYear()) ; // TO DO: write remainder of body of this method here } }