Question: Ok so i need to write the brick class based on the JavaDoc provided, the is based on the game brick breaker. what other informations

Ok so i need to write the brick class based on the JavaDoc provided, the is based on the game brick breaker.

what other informations do you need??

how do i write this class?? need help please

  • public class Brick extends java.lang.Object

    This class is used to store state information corresponding to a single Brick within the brick breaker game model. It provides basic information about the Brick's position as well as information about the current strength of a Brick. All Bricks in brick breaker have a height of 20 and a width of 50, regardless of other state information.

    Author:

    bdorn

    • Constructor Summary

      Constructors
      Constructor and Description
      Brick(int topIn, int leftIn)

      Creates a basic Brick object at a specified position.

      Brick(int topIn, int leftIn, int hitsIn)

      Creates a custom Brick object at a specified position with a specified strength.

    • Method Summary

      All Methods Instance Methods Concrete Methods
      Modifier and Type Method and Description
      javafx.scene.paint.Color getColor()

      The current color to represent this Brick's breakability state.

      int getHeight()

      Retrieves the height of this Brick.

      int getLeft()

      Retrieves the x coordinate of the left side of this Brick.

      int getTop()

      Retrieves the y coordinate of the top of this Brick.

      int getWidth()

      Retrieves the width of this Brick.

      boolean hit()

      This mutator method will update this Brick's state data to account for being hit by the Ball once.

      TouchPosition isTouching(Ball theBall)

      This method implements a collision detection algorithm to identify whether this Brick is currently being hit by a given Ball object.

      java.lang.String toString()

      Retrieves a String representation of this Brick's current object state.

      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Brick

        public Brick(int topIn, int leftIn)

        Creates a basic Brick object at a specified position. The new Brick will default with a strength of 3, meaning that it will break after 3 hits by a ball.

        Parameters:

        topIn - The y position of the top of this Brick in the model.

        leftIn - The x position of the left side of this Brick in the model.

      • Brick

        public Brick(int topIn, int leftIn, int hitsIn)

        Creates a custom Brick object at a specified position with a specified strength.

        Parameters:

        topIn - The y position of the top of this Brick in the model.

        leftIn - The x position of the left side of this Brick in the model.

        hitsIn - The initial strength of this Brick. A value greater than zero represents that this Brick will break after that number of hits. A value of 0 represents a "non-brick" or empty space in the model. A value of -1 represents that this Brick cannot be broken at all, regardless of the number of hits.

    • Method Detail

      • getTop

        public int getTop()

        Retrieves the y coordinate of the top of this Brick.

        Returns:

        The y coordinate of the top edge.

      • getLeft

        public int getLeft()

        Retrieves the x coordinate of the left side of this Brick.

        Returns:

        The x coordinate of the left edge.

      • getWidth

        public int getWidth()

        Retrieves the width of this Brick.

        Returns:

        The width of the Brick.

      • getHeight

        public int getHeight()

        Retrieves the height of this Brick.

        Returns:

        The height of the Brick.

      • getColor

        public javafx.scene.paint.Color getColor()

        The current color to represent this Brick's breakability state.

        Returns:

        There are five possible Colors that can be returned based on the Brick's current strength: Color.BLACK if this Brick cannot be broken; Color.WHITE if this Brick has been completely broken; and Color.RED, Color.YELLOW, Color.GREEN if this Brick will break after 1, 2, and 3 more hits, consecutively.

      • hit

        public boolean hit()

        This mutator method will update this Brick's state data to account for being hit by the Ball once.

        Returns:

        true when the hit caused this brick to break completely, false otherwise.

      • isTouching

        public TouchPosition isTouching(Ball theBall)

        This method implements a collision detection algorithm to identify whether this Brick is currently being hit by a given Ball object. It will produce a return value to signal which side, if any, is currently being hit.

        Parameters:

        theBall - The Ball to examine for collision with this Brick.

        Returns:

        A valid TouchPosition state representing where theBall is intersecting this Brick. When no collision is detected at all or this Brick is already broken, NONE should be returned. Otherwise, TOP, BOTTOM, LEFT, or RIGHT will be returned corresponding to which side of this Brick is currently being hit by theBall.

      • toString

        public java.lang.String toString()
        Retrieves a String representation of this Brick's current object state. The string will be formatted as:

        "Brick at (tlx, tly, brx, bry)" where tlx/tly are the x and y coordinates of the top/left corner and brx/bry are the x and y coordinates of the bottom right corner of this Brick.

        Overrides:

        toString in class java.lang.Object

        Returns:

        The formatted state information about this Brick.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!