RHS   Allan   SW construction Exercises SimpleArray


 

SimpleArray

Create a class - SimpleArray - that holds an array with 500 elements of the type int.

Constructor
When an object is instantiated the 500 elements should be initialized to random numbers in the range 0 - 999.
To get a random number between 0 (inclusive) and 1 (not inclusive) use: Math.random();
To convert this to an integer number between 0 (inclusive) and 1000 (not inclusive) use: (int) (Math.random() * 1000);

Methods
Implement the following methods in the class:

Testing class
Now implement a testing class using a GUI called TestSimpleArray.
In the testing class you should create an object from the SimpleArray class and test all its methods.

Extension
Extend the class SimpleArray (remember to change the testing class accordingly so you still test all methods) with the following methods:

Extra - StringArray
Change SimpleArray (and the testing class) so the array holds Strings instead of int-values!


Maintained by: Allan Helboe Nielsen
Updated: 3 November, 2005 1:04