I am trying to solve the following question:
Implement a class called TriangleArray which has the following: No other instance variables or constants allowed.
- An instance variable called list which is an array of Triangle objects.
- No other instance variables or constants allowed.
- Only one constructor which has two integer parameters. The first parameter called number is the length of list. The second parameter called maxSize is the maximum size allowed for the
- The constructor initializes list to an array of Triangle objects.
- The sides of each Triangle object are randomly generated integers in the range from 1 to maxSize.
- Getter and setter methods for list.
- A largest method with no parameters. The method returns the largest Triangle in list.
- A toString method which returns a description of each Triangle in list.
How can I populate the list full of random objects without using other instance variable?
Here is the code that I have so far:
import java.util.Random;
public class TriangleArray
{
private Triangle[ ] list;
// list is an array of "number" Triangle objects.
// The maximum size of each Triangle edge is "maxSize".
public TriangleArray (int number, int maxSize);
{
list = new Triangle[number];