Exercise 4 (Generic Types)
Completion requirements
Opened: Thursday, 23 April 2015, 5:00 PM
Due: Saturday, 2 May 2015, 6:00 AM
Implement a Generic Class Duple:
Implement a generic class which represents a duple of two numbers of the same type.- The class should accept all the subtypes of java.lang.Number.
- Both numbers are of the same type.
- Implement the following interface:
/**
* This interface defines methods to obtain the signum of two numbers.
*/
public interface Signum {
/**
* Returns the signum of the first number. That is, -1 for negative values,
* 1 for positive values, and 0 otherwise.
*/
int signumFirst();
/**
* Returns the signum of the second number. That is, -1 for negative values,
* 1 for positive values, and 0 otherwise.
*/
int signumSecond();
} - Provide a constructor with the two numbers as its arguments, and follow the concept of encapsulation. I.e. provide methods to get (the so called Getter) and set (the so called Setter) the values of the numbers.