- Pair Utils
Create class Pair. It should have two fields representing Key and Value. Pair should be generic class with two type parameters one for key and one for value.
Create static PairUtils class.
There should be following methods:
- equals - verify whether two pairs equals with the same key, value types;
- compareTo - compare two pairs. Key types should implement java.lang.Comparable;
- getValues - get array of values for array of pairs;
- getKeys - get array of keys for array of pairs;
- countGreaterThan - count pairs with keys greater than specified parameter. Key type and specified parameter type should be the same;
- containsUniqueObjects - check whether array of pairs contains only unique keys.
- Generic Container
Create class container the same as for https://github.com/ChangeRequest/oop.hw1 but instead of Integer it should work with elements of any type.
There should be should be following methods:
- size - get container size
- clear - clear all container
- add(E) - add element E to the end
- get - get element at specified position
- add(E, I) - add element E to specified position I
- remove - remove element at specified position
Create demo program which demonstrates how Container works.
- Number Generators
Create abstract class NumberGenerator, with only method generateNumbers. It should return container with any of subtypes java.lang.Number and be abstract.
Create IntegerGenerator class which extends NumberGenerator and implement method generateNumbers. Method should return Container with 10 Integers.
Create DoubleGenerator class which extends NumberGenerator and implement method generateNumbers. Method should return Container with 10 Doubles.
Create class Printer, which contains field NumberGenerator and method generateAndPrint. It should generate numbers and print their sum.
NOTE: Feel free to extend classes with any additional data: fields, methods, generic types and so on.