Description: This project focuses on creating a Java class, Date.java, along with a client class, DateCleint.java, which will contain code that utilizes your Date.java class. You will submit both files (each with appropriate commenting). A very similar project is described in the Programming Projects section at the end of chapter 8, which you may find helpful as reference.

Use (your own) Java class file Date.java, and a companion DateClient.java file to perform the following:

  • Ask user to enter Todays date in the form (month day year): 2 28 2018
  • Ask user to enter Birthday in the form (month day year): 11 30 1990
  • Output the following:
    • The date they were born in the form (year/month/day).
    • The day of the week they were born (Sunday Saturday).
    • The number of days between their birthday and todays date (their age in days).
Example: You were born on 1990/11/30, which was a Friday.
You are 9952 days old.

To do this you will need to design, implement and test a Java class file, Date.java:

Date.java is a class of objects which you write, then utilize in DateClient.java to solve the problem above. The Date.java class needs to have the following methods (the object calling the methods below is referenced by this Date object in all the descriptions, as needed).

  • public Date(int year, int month, int day)
    //constructor to create new Date object with given year, month and day.
  • public Date()
    //constructor to create new default Date object with date January 1, 1753 (1753 1 1). (As a side note, January 1, 1753 was a Monday, which will be used later).
  • public int getYear()
    //accessor method to return this Date objects year (between 1753 and 9999).
  • public int getMonth()
    //accessor method to return this Date objects month (between 1 and 12).
  • public int getDay()
    //accessor method to return this Date objects day (between 1 and 31).
  • public String toString()
    //accessor method to return String of this Date objects field in form Year/Month/Day (2018/2/28).
  • public boolean equals(Date otherDate)
    //accessor method to return true if this Date object equals otherDate object (false otherwise).
  • public Boolean isLeapYear()
    //accessor method to return true if this Date objects year field is leap year (false otherwise). Leap years are all years divisible by 4, except those also divisible by 100, but includes those that are divisible by 400. [1756, 2004, 1600 & 2000 are leap years, but 1755, 1900 and 2100 are not].
  • pubic void nextDay()
    //mutator method that advances this Date objects fields to represent the next date. If this Date objects fields are 2018/2/28, then calling nextDay() method will advance it to 2018/3/1. Similarly, if starting with 2018/12/31, calling nextDay() method will advance it to 2019/1/1. In other words, nextDay() advances this Date objects day, month and/or year, as needed, to the next day.
  • public int advanceTo(Date endDate)
    //mutator method that advances this Date objects fields to the endDate objects fields and returns the number of days between the two dates. Like nextDay(), advanceTo(Date endDate) can advance days, months and/or years as needed. It may be assumed that the endDate objects date is after this Date objects date.
  • public String getDayOfWeek()
    //accessor method that returns a string giving the day of the week this Date objects date falls on (Sunday thru Saturday). (We will need to know the day of a start date, for which we can use that January 1, 1753 was a Monday.) This method should be written utilizing the other methods listed aboveno outside code from internet or elsewhere is needed.

None of the methods within the Date.java class should interact directly with the user or print anything to the console. All interaction with the user (and the console) should be contained within DateClient.java class.

You may not use any of Javas date-related classes, nor should you use any code or fragments of code obtained through outside or internet research. The concepts needed here rely on content from chapters 1-8 in our text, and development of these ideas independent of outside resources is the purpose of this assignment.

Development strategy:

  • Write constructor and get*() methods in Date.java class.
  • Write a DateTesting.java class to test all methods utilizing Date.java class.
  • Write toString, equals & isLeapYear accessor methods in Date.java class.
  • Write nextDay, (you may want to write an additional intermediate method that returns the number of days in this Date objects month. You will also need to call isLeapYear within this method.)
  • Write advanceTo by utilizing other methods written within Date.java class.
  • Write getDaysOfWeek, again utilizing other methods written within the Date.java class.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.