Record Class Action

java.lang.Object
java.lang.Record
nz.ac.vuw.ecs.swen225.gp22.recorder.Action
Record Components:
entityID - The id of the entity.
actionType - The type of action.
x - The x coordinate of the action.
y - The y coordinate of the action.
prevDir - The previous direction.
currDir - The current direction.
color - The color of the tile. Can be None.

public record Action(int entityID, String actionType, int x, int y, String prevDir, String currDir, String color) extends Record
The action class to update the game.
Author:
Chris
  • Constructor Summary

    Constructors
    Constructor
    Description
    Action(int entityID, String actionType, int x, int y, String prevDir, String currDir, String color)
    Creates an instance of a Action record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the actionType record component.
    Returns the value of the color record component.
    Returns the value of the currDir record component.
    int
    Returns the value of the entityID record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Returns the value of the prevDir record component.
    final String
    Returns a string representation of this record class.
    org.dom4j.Element
    Creates an XML element from the action.
    int
    x()
    Returns the value of the x record component.
    int
    y()
    Returns the value of the y record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Action

      public Action(int entityID, String actionType, int x, int y, String prevDir, String currDir, String color)
      Creates an instance of a Action record class.
      Parameters:
      entityID - the value for the entityID record component
      actionType - the value for the actionType record component
      x - the value for the x record component
      y - the value for the y record component
      prevDir - the value for the prevDir record component
      currDir - the value for the currDir record component
      color - the value for the color record component
  • Method Details

    • toxml

      public org.dom4j.Element toxml()
      Creates an XML element from the action.
      Returns:
      the XML element
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • entityID

      public int entityID()
      Returns the value of the entityID record component.
      Returns:
      the value of the entityID record component
    • actionType

      public String actionType()
      Returns the value of the actionType record component.
      Returns:
      the value of the actionType record component
    • x

      public int x()
      Returns the value of the x record component.
      Returns:
      the value of the x record component
    • y

      public int y()
      Returns the value of the y record component.
      Returns:
      the value of the y record component
    • prevDir

      public String prevDir()
      Returns the value of the prevDir record component.
      Returns:
      the value of the prevDir record component
    • currDir

      public String currDir()
      Returns the value of the currDir record component.
      Returns:
      the value of the currDir record component
    • color

      public String color()
      Returns the value of the color record component.
      Returns:
      the value of the color record component