Record Class Entity.Action
java.lang.Object
java.lang.Record
nz.ac.vuw.ecs.swen225.gp22.domain.Entity.Action
- Record Components:
id- ID of the entity this action belongs to.moveVector- Amount the entity moved by in this action.oldDir- Direction entity was facing before action.newDir- Direction entity is facing after action.interaction- The interaction, if any that happened this action.
- Enclosing class:
- Entity<S extends Observable<S>>
public static record Entity.Action(int id, Maze.Point moveVector, Entity.Direction oldDir, Entity.Direction newDir, Entity.Action.Interaction interaction)
extends Record
A record used to store an action taken. This will be
used to revert actions when replaying a game.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRepresents an interaction with a tile that happened in the action. -
Constructor Summary
ConstructorsConstructorDescriptionAction(int id, Maze.Point moveVector, Entity.Direction oldDir, Entity.Direction newDir, Entity.Action.Interaction interaction) Creates an instance of aActionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intid()Returns the value of theidrecord component.Returns the value of theinteractionrecord component.Returns the value of themoveVectorrecord component.newDir()Returns the value of thenewDirrecord component.oldDir()Returns the value of theoldDirrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Action
public Action(int id, Maze.Point moveVector, Entity.Direction oldDir, Entity.Direction newDir, Entity.Action.Interaction interaction) Creates an instance of aActionrecord class.- Parameters:
id- the value for theidrecord componentmoveVector- the value for themoveVectorrecord componentoldDir- the value for theoldDirrecord componentnewDir- the value for thenewDirrecord componentinteraction- the value for theinteractionrecord component
-
-
Method Details
-
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 '=='. -
id
public int id()Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
moveVector
Returns the value of themoveVectorrecord component.- Returns:
- the value of the
moveVectorrecord component
-
oldDir
Returns the value of theoldDirrecord component.- Returns:
- the value of the
oldDirrecord component
-
newDir
Returns the value of thenewDirrecord component.- Returns:
- the value of the
newDirrecord component
-
interaction
Returns the value of theinteractionrecord component.- Returns:
- the value of the
interactionrecord component
-