Package ch.hevs.kart
Class KartSequence.Instruction
java.lang.Object
ch.hevs.kart.KartSequence.Instruction
- Enclosing class:
KartSequence
Instruction class, represents a single instruction (opcode + operand).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Enumerates the opcodes actually supported by the Kart's sequencer vm. -
Constructor Summary
ConstructorsConstructorDescriptionInstruction
(KartSequence.Instruction.OpCode opCode, short operand) A complete kart instruction consisting of an opcode and an operand. -
Method Summary
Modifier and TypeMethodDescriptionstatic KartSequence.Instruction
fromString
(String string) Tries to convert a string into an instruction.Returns the opcode (command) of the instruction.short
Returns the operand (argument) of the instruction.void
setOperand
(short operand) Changes the operand (argument) of the instruction.toString()
Returns a string representation of the instruction.toXmlTag()
Converts the instruction to an XML tag that can be embedded into XML files.
-
Constructor Details
-
Instruction
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
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
Converts the instruction to an XML tag that can be embedded into XML files.
- Returns:
- XML tag representing the instruction.
-
toString
Returns a string representation of the instruction.
-
fromString
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.
-