Module project.pong

Class Racket

java.lang.Object
project.pong.model.Racket
All Implemented Interfaces:
Resizable

public class Racket extends Object implements Resizable
The Racket class represents a racket in the Pong game.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Racket(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 Type
    Method
    Description
    javafx.scene.paint.Color
    Gets the color of the racket.
    double
    Gets the height of the racket.
    int
    Gets the speed of the racket.
    double
    Gets the width of the racket.
    double
    Gets the x-coordinate of the racket's position.
    double
    Gets the y-coordinate of the racket's position.
    void
    move(int direction)
    Moves the racket based on the specified direction.
    void
    Moves the racket down by its speed.
    void
    Moves the racket up by its speed.
    void
    resizeHeight(double factor)
    Resizes the object's height by the specified factor.
    void
    resizeWidth(double factor)
    Resizes the object's width by the specified factor.
    void
    setHeight(double height)
    Sets the height of the racket.
    void
    setSpeed(int speed)
    Sets the speed of the racket.
    void
    setWidth(double width)
    Sets the width of the racket.
    void
    setX(double x)
    Sets the x-coordinate of the racket's position.
    void
    setY(double y)
    Sets the y-coordinate of the racket's position.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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

      public String toString()
      Overrides:
      toString in class Object
    • resizeWidth

      public void resizeWidth(double factor)
      Description copied from interface: Resizable
      Resizes the object's width by the specified factor.
      Specified by:
      resizeWidth in interface Resizable
      Parameters:
      factor - The factor by which to resize the width.
    • resizeHeight

      public void resizeHeight(double factor)
      Description copied from interface: Resizable
      Resizes the object's height by the specified factor.
      Specified by:
      resizeHeight in interface Resizable
      Parameters:
      factor - The factor by which to resize the height.