Question: We just leaned aliitle bit up to the interface, please write code clearly and I wanna to learn from it, thank you so much^^ This

We just leaned aliitle bit up to the interface, please write code clearly and I wanna to learn from it, thank you so much^^

We just leaned aliitle bit up to the interface, please write code

This is the calculate interface:

package interfaces; public interface Calculable { public E add(E o); public E subtract(E o); } 

General Description Download the Calculable interface. You will implement this interface in Money and Time classes which you will create. Please use package declaration hw7 for this project. The Money Class .Create a class to represent money . Add any necessary data fields, constructors, getters/setters, and other methods This class should implement the Comparable and Calculable interfaces Implement the methods from these interfaces add should add two Money objects together and return the sum of the two as a new Money object subtract should subtract two Money objects and return the difference of the two as a new Money object. o o NOTE: Money can be negative, but the negative sign should only be displayed on the dollars part, not the cents part. You will need to account for the fact that cents can only go up to .99 before rolling over to the next dollar amount. compare To should be able to compare two money objects. It will be used later to sort a list of Money objects o .Also implement a Copy Constructor to make a deep copy of the object. .Implement toString to display money in the form S1.59 or S-1.59 with only two decimal places The Time Class: .Create a class to represent Time. .Add any necessary data fields, constructors, getters/setters, and other methods This class should implement the Comparable and Calculable interfaces o Implement the methods from these interfaces o add should add two Time objects together and return the sum of the two as a new Time object. o subtract should subtract two Time objects and return the difference of the two as a new Time object. NOTE: Time cannot be negative You will need to account for the fact that seconds can only go up to 59 before rolling over to the next minute, minutes can only go up to 59 before rolling over to the next hour, hours can only go up to 12 (or 24 if you implement 24 hour time) before rolling over to 1 o'clock again. (Or in the case of negative time, you should roll over in the opposite direction) compareTo should be able to compare two Time objects. It will be used later to sort a list of Time objects . For comparison purposes, an AM time should appear in a sorted list BEFORE a PM time .Also implement a Copy Constructor (explained in Lab class) to make a deep copy of the object. .Implement toString to display Time in the form hours minutes:seconds AM or PM, i.e. 03:04:45 AM The Main Class Create two ArrayLists of five Money objects each (add the objects in an unsorted order). Use Collections.sort) to sort each ArrayList. See the Java APl on how to use Collections.sort0). Take each pair of lists and add the corresponding elements together and display the results .Create two ArrayLists of five Time objects each (add the objects in an unsorted order). .Display each list before and after being sorted. o I.E. Take both Money lists and add together both elements at index 0, index 1, index 2, etc o Do the same for the Time lists Take each pair of lists and subtract the corresponding elements, and display the results o I.E. Take both Money lists and subtract both elements at index 0, index 1, index 2, etc... o Do the same for the Time lists

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!