Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Implement the EnhancedTime class: Implement the addSeconds method in the EnhancedTime class in the P2 folder using the instructions below. You are NOT allowed to
Implement the EnhancedTime class: Implement the addSeconds method in the EnhancedTime class in the P2 folder using the instructions below. You are NOT allowed to create any other methods, instance variables, or make any changes to methods other than addSeconds or files other than "EnhancedTime.java". You will lose points if you do. The addSeconds method adds a certain number of seconds to the time represented by the current Time object. The changes should be left on the current object. First, create an object of the EnhancedTime class in the test driver with an initial time and then call the addSeconds method on this object. For example, say you create a new object using the EnhancedTime class, named currentTime, and this new object contains the time 11:59:59 AM. You would then call the addSeconds(1) method on the currentTime object, making the time be 12:00:00 PM because 1 second has been added to the original time. If the current time is 08:17:36 PM and 18,000 seconds (5 hours) are added, the new time would be 01:17:36 AM. Note that adding a large number of seconds can move the time across days, and you need to update AM and PM for the time properly. Do NOT use any off-the-shelf implementations (e.g. Java's built-in time library and its methods) for the above method. You are required to do it from scratch using basic date structures! Sample Output: The current time is 11:59:59 AM and 60 seconds are added. The correct new time is 12:00:59 PM and the one calculated by your program is 12:00:59PM. Correct! The current time is 06:12:27 AM and 60 seconds are added. The correct new time is 06:13:27AM and the one calculated by your program is 06:13:27 AM. Correct! *. The current time is 02:18:27PM and 123456 seconds are added. The correct new time is 12:36:03 AM and the one calculated by your program is 12:36:03 AM. Correct! The current time is 04:38:32 AM and 4568915 seconds are added. The correct new time is 01:47:07 AM and the one calculated by your program is 01:47:07 AM
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started