Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help writing this class. Constructor Detail Brick public Brick(int topin, int leftIn) Creates a basic Brick object at a specified position. The new Brick

Need help writing this class.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

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. is Touching 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 Touch Position 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. to String 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. 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. is Touching 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 Touch Position 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. to String 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions

Question

What is American Polity and Governance ?

Answered: 1 week ago

Question

b. What groups were most represented? Why do you think this is so?

Answered: 1 week ago

Question

3. Describe phases of minority identity development.

Answered: 1 week ago

Question

5. Identify and describe nine social and cultural identities.

Answered: 1 week ago