this is the given code !

public class TestTwoDimArray
{
    private final int rows = 10;
    private final int cols = 20;
    private final int diameter = 20;
    /*
    Add a two-dimensional Circle array field to hold your circles.
    */
 
 
    /**
     * Creates an empty 2-dimensional Circle array.
     */
   
    /*
    Write a constructor method that initializes the array.
    The first dimension should be given size rows, and
    the second dimension should be given size cols.
    */
 
   
    /**
     * Fill the array with circles.
     */
    /*
    Write a method called "fillArray" that fills the entire
    array with blue circles.  Give all circles the same diameter
    using the field defined above.
    Circles in the same row should have the same yPosition.
    Circles in the same column should have the same xPosition.
    The yPosition for row 0 should be 0.
    The yPosition for row 1 should be diameter.
    The yPosition for row 2 should be 2*diameter...
    Continue this pattern for all rows.
    Use a similar pattern to set the xPosition of each circle in a given column.
    If you do this correctly, no circle will overlap another circle.

    Once you get this working, then fix your code so that it does not
    add circles to positions in the array that are already occupied by
    a circle.  You can tell whether a position is empty by checking if
    it contains null.
    */
 

    /**
     * Add a random number of circles (between 1 and rows * cols).
     * Only need one loop here;
     */
    /*
    Write a method called "addSomeCircles" that tries to add a random
    number of red circles to the array in a random fashion.  The
    number of circles it tries to add should be between 1 and
    rows*cols, inclusive.  For each circle choose a random row number and a
    random column number.  The x and y positions of the circle should
    follow the plan used in the "fillArray" method. If the array has
    no circle at that position, add one, otherwise move on. Your
    method should return the number of collisions you had while adding
    circles. Remember, an empty element in the array will be equal (i.e., ==) to
    null.
   
   
    */

    /**
     * Add a single circle at (row,col).
     * Make sure you account for arrays having positions from 0 to n and test for entering an invalid position
     */
    /*
    Write a method called "addSingleCircle" that takes an integer
    parameter for the row and an integer parameter for the column.  If
    the coordinates specify a valid position in the array, and the
    array has no circle at that position, then add a green one,
    otherwise do nothing.  The x and y position of the circle should
    follow the plan used in the "fillArray" method.
    */
   
    /**
     * Makes all circles in the array visible.
     */
    /*
    Write a method called "makeAllCirclesVisible" that makes
    all circles in the array visible.
    */

    /**
     * Makes all circles in the array invisible.
     */
    /*
    Write a method called "makeAllCirclesInvisible" that makes
    all circles in the array invisible.
    */

    /**
     * Remove all circles from the array.
     */
    /*
    Write a method called "emptyArray" that removes all circles from
    the array (i.e. make them all null.) (Don't forget to make them all
    invisible first.)
    */
}

ليست هناك تعليقات:

إرسال تعليق