You need to write a function that takes an array of integers and returns an array of a new type of object that you will create the class for.
- Create a new class in the
learnsomejavapackage calledObjectDoubler - Add a method (accessible from within the package) called
setNumber()that stores a number in a class variable. - Add a method (accessible from within the package) called
getMeDoubled()that returns the number doubled. - In the
Learnclass create astatic method(Google it) calledcreateDoublersthat takes an array of integers, returns an array ofObjectDoublerclasses, one for each integer with thesetNumbermethod called with the next number in the array.
e.g.
Doing the following
int[] numArray = {1, 2, 3, 4, 5};
Learn.createDoublers(numArray);will create an array of ObjectDoubler objects which calling getMeDoubled() on would return 1, 4, 6, 8, 10.
Look at the Test.java class for examples.