Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

And here is the tester file public interface IDate{ * Since this is the first interface you will use, a couple of notes: * 1)

image text in transcribed

And here is the tester file

image text in transcribed

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())

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

More Books

Students also viewed these Databases questions

Question

What are the different ways to enhance a product's position?

Answered: 1 week ago

Question

How social media can help comapnies?

Answered: 1 week ago