with ada.text_io; use ada.text_io; 
with ada.integer_text_io; use ada.integer_text_io; 
with ada.numerics.discrete_random;

procedure linelist is

    type point is record
        x, y: Integer;
    end record;

    type line is record
        p1, p2: Point;
    end record;

    Max_Lines: Constant Natural := 100;
    type Line_Array is array(1 .. Max_Lines) of Line;

    type List is record
        -- theLines: array(1 .. Max_Lines) of Line; -- Compile error
        theLines: Line_Array;
        len: Natural := 0;
    end record;
    
    -- Use input to fill up the list
    procedure get_list(l: out list) is
    begin
        -- Fix the compile error!
        while not end_of_file loop
            get(l.thelines(i).p1.x);
            get(l.thelines(i).p1.y);
            get(l.thelines(i).p2.x);
            get(l.thelines(i).p2.y);

            l.len := l.len + 1;
        end loop;
    end get_list;


    -- Fill up the list using random numbers
    procedure random_fill_list(l: out list) is

        -- Create and use a new package to create random integers
        package randomintpkg is new ada.numerics.discrete_random(Integer);
        use randomintpkg;

        size: Integer;  -- number of lines to fill
        g: generator;   -- Random number generator

    begin
        -- input the number of lines to fill
        get(size);  

        -- input size lines
        for i in 1 .. size loop
            l.thelines(i).p1.x := random(g);
            l.thelines(i).p1.y := random(g);
            l.thelines(i).p2.x := random(g);
            l.thelines(i).p2.y := random(g);
        end loop;

        -- The list must store the number of valid elements
        l.len := size;
    end random_fill_list;

    -- Output the list of lines
    procedure print_list(l: in list) is
    begin
        -- The loop and the put need to be finished
        -- for i in 1 .. ??? loop
            -- put(l);  
            new_line;
        -- end loop;

    end print_list;

    theList: list; 

begin
    -- Select on of the two ways to fill up the list: random or with input
    -- get_list(theList);
    random_fill_list(theList);

    print_list(theList);
end linelist;