Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 FutureDate 10 marks In this problem you will implement a single static method that outputs an array of black-box test cases for the futureDate)

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

1 FutureDate 10 marks In this problem you will implement a single static method that outputs an array of black-box test cases for the futureDate) method from Tutorial 5. The method you will implement, in the TestFutureDate class, is specified as follows Generate black-box test cases for the futureDate method The API for the futureDate) method is provided in this Assignment document * Greturn an array of test cases for the futureDate) method public static FutureDateTestCase makeTestCases O...h Each test case consists of a Date object, an integer (that is the number of days in the future), and another Date object that is the expected date in the future. For example, consider Date day-new Date (2019, 1, 1); int daysInFuture-2; Date expectednew Date (2019, 1, 1+daysInFuture) FutureDateTestCase testcase new FutureDateTestCase (day, daysInFuture, expected); This creates a test case to check that the expected Date is 2 days in the future from the day object. That is, it checks that January 3, 2019 is 2 days in the future from January 1, 2019. This is a valid test case because the expected output is correct Each of your test cases will first be run with a correct implementation of the futureDate () method. If the actual output matches the expected output (specified in the test case) then that test case is deemed to be valid. Each valid test case will then be run with several alternate versions of the method that have bugs in them. Test cases that are invalid will be discarded. A bug is exposed each time a valid test case fails in an alternate version of the method. That is, when the outcome of the method does not match the expected outcome of the test case then something went wrong in the method (and hence a bug is exposed). A failed test case does not necessarily indicate what or where the bug is but it does let you know that a bug exists Your goal is to generate a collection of valid test cases that expose a bug in each of the alternate versions (buggy versions) that we will have on the server. Your grade will be determined by the number of alternate versions that you find a bug in. The API for the futureDate ) method is as follows: /** Creates a new date object that is some specified number of days * in the future from date object calling it. *Precondition: the current Date object calling this method will always c orrespond to a date tht is NOT further in the past than August 26, 1735. * Oparam daysInFuture is a non-negative integer (the number of days from this date that the new returned date object will be created) * Greturn a new Date obiect that is daysInFuture past this current date. public Date futureDate(int daysInFuture)... public class Date protected int year protected int month protected int day: Creates a date with the specified year, month and date. eparam YYYY is the year of the date to be created. param MM is the month of the date to be created. Eparam DD is the day of the date to be created public Date (int YYYY, int MM, int DD) year YYYY; month -MM dayDD Getter for the year of this date *return the year of this date public int getYear ( return this.year: Getter for the month of this date *@return the month of this date public int getMonth ) return this.month h /Getter for the day of this date *return the day of this date public int getDay) return this.day: h Creates a new date object that is nDays in the future * from this current date param nDays is a non-negative integer (the number of days from this date that the new returned date object will be created). *return a new date object that is nDays past this current date. public Date futureDate (int nDays) return null: **Creates a new date object that is nDays in the future *from this current date @param nDays is a non-negative integer (the number of days from this date that the new returned date object will be created) *return a new date object that is nDays past this current date public Date futureDate (int nDays) return null: *A string representation of this date *return a string representation of this date as YYYY/MM/DD @Override public String toString (O return String. format("%04d", this . year) + "/" + String.format("%02d", this.month) + "/" + String . format ("%02d", this.day); /** A c1a35 for blackbox te ting */ public class EutureDate protected static int[] days1nMonth {31,28,31,30,31,30,31,31,30,31,30,31}; protected static String[] months"January", "February"March", "April","May","June"July","August", "September","October", "November","December" **Creates a new futuredate object that is nDays in the future from this current futuredate object

Example: d.makeFutureDate (0) wi1l create a new futuredate object that is the same date a3 fd

Example: fd.makeFutureDate(1) will create a new futuredate object that 15 1 day after the uturedate Id

Example: Ed.makeFutureDate (3) will create a new futuredate object that is 3 days p5t the futuredate fd 8param nDays is a non-negative integer (the number ot days from this futuredate that the new returned futuredate object will be created) * @return a new futuredate object that 1 nDays pa t thi current futureaate. public FutureDate makeFutureDate (int nDays) if( this. day + nDays Example: d.makeFutureDate (0) wi1l create a new futuredate object that is the same date a3 fd

Example: fd.makeFutureDate(1) will create a new futuredate object that 15 1 day after the uturedate Id

Example: Ed.makeFutureDate (3) will create a new futuredate object that is 3 days p5t the futuredate fd 8param nDays is a non-negative integer (the number ot days from this futuredate that the new returned futuredate object will be created) * @return a new futuredate object that 1 nDays pa t thi current futureaate. public FutureDate makeFutureDate (int nDays) if( this. day + nDays

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

Microsoft SQL Server 2012 Unleashed

Authors: Ray Rankins, Paul Bertucci

1st Edition

0133408507, 9780133408508

More Books

Students also viewed these Databases questions

Question

To what microcultural groups do you belong?

Answered: 1 week ago