Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Step 2: Implement the following methods for the class GeoCountDownTimer - initial code provided. Implement the following methods and properties/instance variables in GeoCountDownTimer class. Properties/instance

Step 2: Implement the following methods for the class GeoCountDownTimer - initial code provided.

Implement the following methods and properties/instance variables in GeoCountDownTimer class.

Properties/instance variables

For properties, you will need three instance variables: year (integer), month (integer), and day (integer).

The valid values of the instance variables are:

  • Year: >= 2022
  • Month: [1-12]
  • Day: [1 to the last day of each month]. Remember the last day of February changes: if the year is a leap year (29), if the year is not a leap year (28)

Methods

You will need to implement the following methods (include any setters or getters that are needed). At this point, assume the values of the input parameters are valid (i.e. within range numbers) this assumption will change in step 5.

NOTES

  • Do not change the headers of the methods
  • You may write any additional private methods to help simplify your code and avoid repeating code.

  • private GeoCountDownTimer() Default constructor that sets the GeoCountDownTimer to zero. (This is interesting, a private constructor, do you know why this would be useful?)
  • public GeoCountDownTimer(int year, int month, int day) A constructor that initializes the instance variables with the provided values.
  • public void GeoCountDownTimer (GeoCountDownTimer other) A constructor that initializes the instance variables with the other GeoCountDownTimer parameter.
  • public GeoCountDownTimer(String geoDate) A constructor that accepts a string as a parameter with the following format: 5/10/2119 where 5 indicates the month, 10 indicates the day, and 2119 indicates the year. You can assume the input has no errors (i.e., a valid set of numbers) contained within.
  • public boolean equals (Object other) A method that returns true if this GeoCountDownTimer object is exactly the same as the other object (Note: you must cast the other object as a GeoCountDownTimer object before doing the comparison).
  • public int compareTo(GeoCountDownTimer other) A method that returns 1 if this GeoCountDownTimer object is greater than the other GeoCountDownTimer object; returns -1 if the this GeoCountDownTimer object is less than the other GeoCountDownTimer; returns 0 if the this GeoCountDownTimer object is equal to the other GeoCountDownTimer object. For example: 1/20/2010 is less than 12/31/2011.
  • public void dec(int days) A method that subtracts the number of days from the this GeoCountDownTimer object This will adjust the timer date down the number of days. (E.g. Current date 1/10/2015 will be 1/5/2015 if passing in 5).

Remember to consider the rolldown of month and year and remember to check for a leap year when necessary.

  • public void dec ()A method that subtracts 1 day from the this GeoCountDownTimer object. Remember to consider the rolldown of month and year and remember to check for a leap year when necessary.
  • public void inc(int days) A method that adds the number of days to the this GeoCountDownTimer object This will adjust the timer date up the number of days. (E.g. Current date 1/10/2015 will be 1/15/2015 if passing in 5). Remember to consider the rolling of month and year and remember to check for a leap year when necessary.
  • public void inc ()A method that adds 1 day from the this GeoCountDownTimer object. Remember to consider the rolling of month and year and remember to check for a leap year when necessary.
  • public String toString() Method that returns a string that represents a GeoCountDownTimer with the following format: month day, year. For example: February 10, 2119
  • public String toDateString() Method that returns a string that represents a GeoCountDownTimer with the following format: month/day/year. For example: 2/20/2119.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books

Students also viewed these Databases questions