Question: Programming Questions You are provided with a Date class and an incomplete IncDate class. The IncDate class inherits from the Date class and it is
Programming Questions
You are provided with a Date class and an incomplete IncDate class. The IncDate class inherits from the Date class and it is supposed to add a certain number of days to a date. This task is done by first creating an object of the IntDate class in the test driver with an initial date and then calling the addDays method on this object. For example, if the current IntDate object, say myDate, contains the date 1/1/2016, then after the addDays(20) method is called on myDate, the date in it would be 1/21/2016 because 20 days has been added to the original date. This is not a simple addition because you need to take care of different months as well as leap years.
a. Completing the IncDate class
Your task is to implement the addDays method in the IncDate class so that calling this method would add a certain number of days to the date contained in the current object. Note that you are only supposed to touch this method. You are NOT allowed to create any other methods, instance variables, or make any changes to methods other than addDays(int numDays) or files other than "IncDate.java". Points will be taken off if you fail to follow this rule.
b. Code Testing
You are provided with a test driver implemented by "TestIncDate.java" (Do not make any changes to this file!) so there is no need to write your own. You are also given a data file "testDates.dat" that contains 30 test dates. This is a binary file and you will not be able to view its content using a text editor. We have not covered how to read and write this type of files so do not worry if you have no idea how it works. We will introduce the topic later this semester. Depending on your programming environment, the data file might need to be placed in different folders so that you test driver can read it. For jGRASP, you can leave the data file in the same folder as your java files. For NetBeans, you should place it in your project folder in which you see directories like build, nbproject, and src, etc. Once you have completed the addDays method, you can run the test. You should create a plain text file named "output.txt", copy and paste the output (if your code crashes or does not compile, copy and paste the error messages) to this file and save it
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
