P2. In this question, you are provided with a Date class and an incomplete EnhancedDate class. The EnhancedDate class inherits from the Date class with two more methods: addDays (int numDays) This method adds a certain number of days to the date represented by the current Date object. The changes should be left on the current object. This task is done by first creating an object of the EnhancedDate class in the test driver with an initial date and then calling the addDays method on this object. For example, if the current EnhancedDate object, say currentDate, contains the date 1/1/2016, then after the addDays (20) method is called on currentDate, 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. daysFrom (Date startDate) – This method computes the number of days elapsed from startDate, and returns an integer. If the startDate is earlier than the current day, the return should be positive, whereas if it is later than the current date, then this method should return a negative number. Hint: you can call the compareTo method provided in the Date class to check which of the two dates is older so that you can always count the days from the older date to the newer date. You may choose to use the above addDays method to simplify this implementation date - you can keep adding a day to the older date until you bring it up to the newer

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
P2.
In this question, you are provided with a Date class and an incomplete
EnhancedDate class. The EnhancedDate class inherits from the Date class with two more
methods:
addDays (int numDays)
This method adds a certain number of days to the date
represented by the current Date object. The changes should be left on the current object.
This task is done by first creating an object of the EnhancedDate class in the test driver with
an initial date and then calling the addDays method on this object. For example, if the current
EnhancedDate object, say currentDate, contains the date 1/1/2016, then after the
addDays (20) method is called on currentDate, 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.
This method computes the number of days elapsed from
daysFrom (Date startDate)
startDate, and returns an integer. If the startDate is earlier than the current day, the return
should be positive, whereas if it is later than the current date, then this method should return a
negative number. Hint: you can call the compareTo method provided in the Date class to
check which of the two dates is older so that you can always count the days from the older date
to the newer date. You may choose to use the above addDays method to simplify this
implementation
date.
- you can keep adding a day to the older date until you bring it up to the newer
Transcribed Image Text:P2. In this question, you are provided with a Date class and an incomplete EnhancedDate class. The EnhancedDate class inherits from the Date class with two more methods: addDays (int numDays) This method adds a certain number of days to the date represented by the current Date object. The changes should be left on the current object. This task is done by first creating an object of the EnhancedDate class in the test driver with an initial date and then calling the addDays method on this object. For example, if the current EnhancedDate object, say currentDate, contains the date 1/1/2016, then after the addDays (20) method is called on currentDate, 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. This method computes the number of days elapsed from daysFrom (Date startDate) startDate, and returns an integer. If the startDate is earlier than the current day, the return should be positive, whereas if it is later than the current date, then this method should return a negative number. Hint: you can call the compareTo method provided in the Date class to check which of the two dates is older so that you can always count the days from the older date to the newer date. You may choose to use the above addDays method to simplify this implementation date. - you can keep adding a day to the older date until you bring it up to the newer
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY