public interface IDate{ * Since this is the first interface you will use, a couple of notes: * 1) Do not edit this document. Any changes will be done and then re-uploaded * 2) In additon to implementing all of the following methods you need a detailed Constructor nt month, int day){... Implementation not shown...); * 3) The following needs to be added to your header: implements IDate public class Date implements IDate{ * 4) There will be a tester file for this project. Write it to specifications, or it will not work! * 5) You will need to store 3 integers representing day, month and year I also stored an int array that stores the days of the month! */ //Moves this IDate forward in time by the given number of days public Date(int year, int month, int day) { public void addDays(int days) { //Moves this IDate forward in time by the given number of weeks //This one is easy once you have done addDays! public void addWeeks(int weeks) { //Returns the number of days that this Date must be adjusted to make it equal to the given other IDate //This one is tough! Make a plan!!! public int daysTo(Date other) { //returns the day value for this IDate public int getDay(){ return day; //returns the month value for this IDate; public int getMonth() { /returns the year value for this IDate; public int getYear(){ //returns true if this IDate falls on a leap year, false if not //A year is a leap year if: //the year is divisible by 4, but not 100...but 400 is ok! //the above statement can be translated to a boolean, and returned ! public boolean isLeapYear(int year){ //Overrides the toString method to display the IDate as "YYYY/MM/DD" public String toString() { //the above doesn't need to be in the interface because it is //already defined in the Object class. I am including it here //to indicate you must override it! import org. junit.Test; import static org. junit.Assert.*; public class DateTester { public DateTester() { // TODO add test methods here. // The methods must be annotated with annotation @Test. For example: // @Test // public void hello() {} @Test public void testString() { IDate date = new Date(2008, 2, 6); assertEquals("February 6, 2008", "2008/02/06", date.toString(); @Test public void testYear() { IDate date = new Date(2008, 2, 6); assertEquals("February 6, 2008", 2008, date.getYear(); @Test public void testMonth() { IDate date = new Date(2008, 2, 6); assertEquals("February 6, 2008", 2, date.getMonth(); @Test public void testDay() { IDate date = new Date(2008, 2, 6); assertEquals("February 6, 2008", 6, date.getDay(); @Test public void testAddDays() { IDate date = new Date(1912, 6, 23);//Alan Turing date.addDays (60000); assertEquals("June 23, 1912: Add 60000 days", "2076/09/30", date.toString(); @Test public void testAddWeeks() { IDate date = new Date(1903, 12, 28);//Von Neumann date.addWeeks (200); assertEquals("December 28, 1903: Add 200 weeks", "1907/10/28", date.toString

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 2GZ
icon
Related questions
Question

public interface IDate{ * Since this is the first interface you will use, a couple of notes: * 1) Do not edit this document. Any changes will be done and then re-uploaded * 2) In additon to implementing all of the following methods you need a detailed Constructor nt month, int day){... Implementation not shown...); * 3) The following needs to be added to your header: implements IDate public class Date implements IDate{ * 4) There will be a tester file for this project. Write it to specifications, or it will not work! * 5) You will need to store 3 integers representing day, month and year I also stored an int array that stores the days of the month! */ //Moves this IDate forward in time by the given number of days public Date(int year, int month, int day) { public void addDays(int days) { //Moves this IDate forward in time by the given number of weeks //This one is easy once you have done addDays! public void addWeeks(int weeks) { //Returns the number of days that this Date must be adjusted to make it equal to the given other IDate //This one is tough! Make a plan!!! public int daysTo(Date other) { //returns the day value for this IDate public int getDay(){ return day; //returns the month value for this IDate; public int getMonth() { /returns the year value for this IDate; public int getYear(){ //returns true if this IDate falls on a leap year, false if not //A year is a leap year if: //the year is divisible by 4, but not 100...but 400 is ok! //the above statement can be translated to a boolean, and returned ! public boolean isLeapYear(int year){ //Overrides the toString method to display the IDate as "YYYY/MM/DD" public String toString() { //the above doesn't need to be in the interface because it is //already defined in the Object class. I am including it here //to indicate you must override it! import org. junit.Test; import static org. junit.Assert.*; public class DateTester { public DateTester() { // TODO add test methods here. // The methods must be annotated with annotation @Test. For example: // @Test // public void hello() {} @Test public void testString() { IDate date = new Date(2008, 2, 6); assertEquals("February 6, 2008", "2008/02/06", date.toString(); @Test public void testYear() { IDate date = new Date(2008, 2, 6); assertEquals("February 6, 2008", 2008, date.getYear(); @Test public void testMonth() { IDate date = new Date(2008, 2, 6); assertEquals("February 6, 2008", 2, date.getMonth(); @Test public void testDay() { IDate date = new Date(2008, 2, 6); assertEquals("February 6, 2008", 6, date.getDay(); @Test public void testAddDays() { IDate date = new Date(1912, 6, 23);//Alan Turing date.addDays (60000); assertEquals("June 23, 1912: Add 60000 days", "2076/09/30", date.toString(); @Test public void testAddWeeks() { IDate date = new Date(1903, 12, 28);//Von Neumann date.addWeeks (200); assertEquals("December 28, 1903: Add 200 weeks", "1907/10/28", date.toString());

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 10 images

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning