/*
 * @topic T01905 ArrayList of Rectangle objects v.2
 * @brief Main driver: ArrayList as method parameter and as a return type
*/
package pckg;

// 
import java.util.ArrayList;

public class SquaresDemo
{
    public static void main(String[] args)
    {
        ArrayList<Rectangle> rectList = getRectangles(); // returns an ArrayList object

        System.out.println("There are " + rectList.size() + " squares in the list\n");

        displayRectangles( rectList );
    }

    //********************************************************************

    public static ArrayList<Rectangle> getRectangles()
    {
        ArrayList<Rectangle> rectList = new ArrayList<Rectangle>();

        for ( int idx = 1; idx <= 5; idx++ )
        {
            rectList.add( new Rectangle( idx, idx ) );
        }

        return rectList;
    }

    //**********************************************************************

    public static void displayRectangles(ArrayList<Rectangle> rectList)
    {
        for ( int idx = 0; idx < rectList.size(); ++idx )
        {
            Rectangle rect = rectList.get( idx );

            rect.displayRectangle();

            System.out.println();
        }

    }
}