java.lang.Object
project.pong.model.Racket
- All Implemented Interfaces:
Resizable
The Racket class represents a racket in the Pong game.
-
Constructor Summary
ConstructorsConstructorDescriptionRacket(double x, double y, double width, double height, javafx.scene.paint.Color color) Constructs a Racket object with the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionjavafx.scene.paint.ColorgetColor()Gets the color of the racket.doubleGets the height of the racket.intgetSpeed()Gets the speed of the racket.doublegetWidth()Gets the width of the racket.doublegetX()Gets the x-coordinate of the racket's position.doublegetY()Gets the y-coordinate of the racket's position.voidmove(int direction) Moves the racket based on the specified direction.voidmoveDown()Moves the racket down by its speed.voidmoveUp()Moves the racket up by its speed.voidresizeHeight(double factor) Resizes the object's height by the specified factor.voidresizeWidth(double factor) Resizes the object's width by the specified factor.voidsetHeight(double height) Sets the height of the racket.voidsetSpeed(int speed) Sets the speed of the racket.voidsetWidth(double width) Sets the width of the racket.voidsetX(double x) Sets the x-coordinate of the racket's position.voidsetY(double y) Sets the y-coordinate of the racket's position.toString()
-
Constructor Details
-
Racket
public Racket(double x, double y, double width, double height, javafx.scene.paint.Color color) Constructs a Racket object with the specified parameters.- Parameters:
x- The x-coordinate of the racket's position.y- The y-coordinate of the racket's position.width- The width of the racket.height- The height of the racket.color- The color of the racket.
-
-
Method Details
-
getY
public double getY()Gets the y-coordinate of the racket's position.- Returns:
- The y-coordinate of the racket's position.
-
setY
public void setY(double y) Sets the y-coordinate of the racket's position.- Parameters:
y- The y-coordinate to set.
-
getWidth
public double getWidth()Gets the width of the racket.- Returns:
- The width of the racket.
-
setWidth
public void setWidth(double width) Sets the width of the racket.- Parameters:
width- The width to set.
-
getHeight
public double getHeight()Gets the height of the racket.- Returns:
- The height of the racket.
-
setHeight
public void setHeight(double height) Sets the height of the racket.- Parameters:
height- The height to set.
-
getSpeed
public int getSpeed()Gets the speed of the racket.- Returns:
- The speed of the racket.
-
setSpeed
public void setSpeed(int speed) Sets the speed of the racket.- Parameters:
speed- The speed to set.
-
moveUp
public void moveUp()Moves the racket up by its speed. -
moveDown
public void moveDown()Moves the racket down by its speed. -
move
public void move(int direction) Moves the racket based on the specified direction.- Parameters:
direction- The direction of movement (1 for up, 2 for down).
-
getColor
public javafx.scene.paint.Color getColor()Gets the color of the racket.- Returns:
- The color of the racket.
-
getX
public double getX()Gets the x-coordinate of the racket's position.- Returns:
- The x-coordinate of the racket's position.
-
setX
public void setX(double x) Sets the x-coordinate of the racket's position.- Parameters:
x- The x-coordinate to set.
-
toString
-
resizeWidth
public void resizeWidth(double factor) Description copied from interface:ResizableResizes the object's width by the specified factor.- Specified by:
resizeWidthin interfaceResizable- Parameters:
factor- The factor by which to resize the width.
-
resizeHeight
public void resizeHeight(double factor) Description copied from interface:ResizableResizes the object's height by the specified factor.- Specified by:
resizeHeightin interfaceResizable- Parameters:
factor- The factor by which to resize the height.
-