Class allRectsTracker

java.lang.Object
  extended by allRectsTracker

public class allRectsTracker
extends java.lang.Object

AllRectsTracker is the monitor class and implements synchronization

Author:
Abhishek

Field Summary
 java.util.LinkedList<Rectangle> allRects
           
static int APPLICATION_HEIGHT
           
static int APPLICATION_WIDTH
           
private static int BRICK_HEIGHT
          Height of a brick
private static int BRICK_SEP
          Separation between bricks
private static int BRICK_WIDTH
          Width of a brick
private static int BRICK_Y_OFFSET
          Offset of the top brick row from the top
 int capacity
           
(package private)  Ball myBall
           
private static int NBRICKS_PER_ROW
          Number of bricks per row
(package private)  Rectangle paddle
           
private static int WIDTH
          Dimensions of game board (usually the same)
 
Constructor Summary
allRectsTracker()
           
 
Method Summary
 void brickConsumer()
          Synchronized method that waits if the shared resource is empty and removes bricks from the applet on collision
 void createBricks()
          Synchronized method that waits if the shared resource is full and creates new bricks on bullet fire
 Rectangle getCollidingObject()
          Gets the method that collides with the ball so that it can be removed from the shared resource and the screen.
 Rectangle getElementAt(double x, double y)
          Checks if there is an object at a given (x,y) position
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

APPLICATION_WIDTH

public static final int APPLICATION_WIDTH
See Also:
Constant Field Values

APPLICATION_HEIGHT

public static final int APPLICATION_HEIGHT
See Also:
Constant Field Values

WIDTH

private static final int WIDTH
Dimensions of game board (usually the same)

See Also:
Constant Field Values

NBRICKS_PER_ROW

private static final int NBRICKS_PER_ROW
Number of bricks per row

See Also:
Constant Field Values

BRICK_SEP

private static final int BRICK_SEP
Separation between bricks

See Also:
Constant Field Values

BRICK_WIDTH

private static final int BRICK_WIDTH
Width of a brick

See Also:
Constant Field Values

BRICK_HEIGHT

private static final int BRICK_HEIGHT
Height of a brick

See Also:
Constant Field Values

BRICK_Y_OFFSET

private static final int BRICK_Y_OFFSET
Offset of the top brick row from the top

See Also:
Constant Field Values

paddle

Rectangle paddle

myBall

Ball myBall

allRects

public java.util.LinkedList<Rectangle> allRects

capacity

public int capacity
Constructor Detail

allRectsTracker

public allRectsTracker()
Method Detail

brickConsumer

public void brickConsumer()
Synchronized method that waits if the shared resource is empty and removes bricks from the applet on collision


createBricks

public void createBricks()
Synchronized method that waits if the shared resource is full and creates new bricks on bullet fire


getCollidingObject

public Rectangle getCollidingObject()
Gets the method that collides with the ball so that it can be removed from the shared resource and the screen.

Returns:
: The brick that the ball collides with

getElementAt

public Rectangle getElementAt(double x,
                              double y)
Checks if there is an object at a given (x,y) position

Parameters:
x - : x co-ordinate of position where object's presence needs to be checked
y - : y co-ordinate of position where object's presence needs to be checked
Returns:
: the object if an object is present at that position . null if there is no object present.