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 -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theactionTyperecord component.color()Returns the value of thecolorrecord component.currDir()Returns the value of thecurrDirrecord component.intentityID()Returns the value of theentityIDrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.prevDir()Returns the value of theprevDirrecord component.final StringtoString()Returns a string representation of this record class.org.dom4j.Elementtoxml()Creates an XML element from the action.intx()Returns the value of thexrecord component.inty()Returns the value of theyrecord component.
-
Constructor Details
-
Action
public Action(int entityID, String actionType, int x, int y, String prevDir, String currDir, String color) Creates an instance of aActionrecord class.- Parameters:
entityID- the value for theentityIDrecord componentactionType- the value for theactionTyperecord componentx- the value for thexrecord componenty- the value for theyrecord componentprevDir- the value for theprevDirrecord componentcurrDir- the value for thecurrDirrecord componentcolor- the value for thecolorrecord component
-
-
Method Details
-
toxml
public org.dom4j.Element toxml()Creates an XML element from the action.- Returns:
- the XML element
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
entityID
public int entityID()Returns the value of theentityIDrecord component.- Returns:
- the value of the
entityIDrecord component
-
actionType
Returns the value of theactionTyperecord component.- Returns:
- the value of the
actionTyperecord component
-
x
public int x()Returns the value of thexrecord component.- Returns:
- the value of the
xrecord component
-
y
public int y()Returns the value of theyrecord component.- Returns:
- the value of the
yrecord component
-
prevDir
Returns the value of theprevDirrecord component.- Returns:
- the value of the
prevDirrecord component
-
currDir
Returns the value of thecurrDirrecord component.- Returns:
- the value of the
currDirrecord component
-
color
Returns the value of thecolorrecord component.- Returns:
- the value of the
colorrecord component
-