-
Notifications
You must be signed in to change notification settings - Fork 0
/
Instruction.php
98 lines (82 loc) · 1.51 KB
/
Instruction.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/**
* Instruction class file
*
* @author Simon Harris
* @package PHPTuring
*/
/**
* Instruction class
*
* @package PHPTuring
*/
class Instruction
{
const MOVE_R = 'R';
const MOVE_L = 'L';
private $initial_state;
private $prereq_symbol;
private $print;
private $move;
private $next;
/**
* @param string $initial_state The name of the Instruction
* @param int $prereq_symbol The prerequisite read symbol
* @param char $print The symbol to print next
* @param char $move The action to perform
* @param string $next The name of the next Instruction to run
*/
public function __construct($initial_state, $prereq_symbol, $print, $move, $next)
{
$this->initial_state = $initial_state;
$this->prereq_symbol = $prereq_symbol;
$this->print = $print;
$this->move = $move;
$this->next = $next;
}
/**
* Returns the Instruction's name
*
* @return string
*/
public function getInitialState()
{
return $this->initial_state;
}
/**
* Returns the Instruction's prerequisite
*
* @return char
*/
public function getPrerequisite()
{
return $this->prereq_symbol;
}
/**
* Return the next symbol to print
*
* @return char
*/
public function getSymbolToWrite()
{
return $this->print;
}
/**
* Return the next required Head move
*
* @return char
*/
public function getNextMove()
{
return $this->move;
}
/**
* Return the next State name
*
* @return string
*/
public function getNextState()
{
return $this->next;
}
}