Package ch.hevs.kart

Class KartSequence.Instruction

java.lang.Object
ch.hevs.kart.KartSequence.Instruction
Enclosing class:
KartSequence

public static class KartSequence.Instruction extends Object

Instruction class, represents a single instruction (opcode + operand).

  • Constructor Details

    • Instruction

      public Instruction(KartSequence.Instruction.OpCode opCode, short operand)

      A complete kart instruction consisting of an opcode and an operand.

      Parameters:
      opCode - Kart sequencer instruction opcode (command).
      operand - Kart sequencer instruction operand (argument).
  • Method Details

    • getOpCode

      public KartSequence.Instruction.OpCode getOpCode()

      Returns the opcode (command) of the instruction.

      Returns:
      Opcode.
    • getOperand

      public short getOperand()

      Returns the operand (argument) of the instruction.

      Returns:
      Operand.
    • setOperand

      public void setOperand(short operand)

      Changes the operand (argument) of the instruction.

      Parameters:
      operand - New operand to set for the instruction.
    • toXmlTag

      @NonNull public String toXmlTag()

      Converts the instruction to an XML tag that can be embedded into XML files.

      Returns:
      XML tag representing the instruction.
    • toString

      @NonNull public String toString()

      Returns a string representation of the instruction.

      Overrides:
      toString in class Object
      Returns:
      Instruction as string.
    • fromString

      public static KartSequence.Instruction fromString(@Nullable String string)

      Tries to convert a string into an instruction. The instruction string should have the format "{OPCODE}:{OPERAND}". Returns null if the string could not be converted into an instruction.

      Parameters:
      string - String to convert the instruction from.
      Returns:
      Instruction converted from the string or null if the string is invalid.