Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class DateObj { private int year; private int month; private int day; private int[] monthLengths = new int[] {31, 28, 31, 30, 31, 30,

image text in transcribed

public class DateObj {

private int year;

private int month;

private int day;

private int[] monthLengths = new int[] {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

public DateObj(int year, int month, int day) {

this.year = year;

this.month = month;

this.day = day;

validate();

}

public DateObj nextDate() {

// TODO: return the next valid date after this one

return null;

}

@Override

public String toString() {

return String.format("Date[year: %d, month: %d, day: %d]", year, month, day);

}

private void validate() {

// TODO: throw an exception if the current values of year, month and day do not

// make a valid date

}

}

1. Download the starter file DateObj.java". Enhance the DateObj class so that it correctly calculates the next date, given some other date. For example, the next date after April 5 2019 is April 6 2019 2. It should correctly handle the following date calculation challenges: a. Handle the various month lengths b. Handle leap years c. Handle transition to next month and next year 3. The input must be a legitimate date. If it is not, throw an IllegalArgumentException 4. The result must be a legitimate date 5. It must work for dates in the past and in the future 6. Provide unit tests to verify each of the above 7. You may not use Java data and calendar classes 8. Execute test cases for achieving full a)statement coverage, b) decision/branch coverage and c) condition coverage. a. If you couldn't cover all statements, branches and conditions implement more test cases to do so. If not possible, consider why

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

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

3rd Edition

0760049041, 978-0760049044

More Books

Students also viewed these Databases questions