Source for file Head.php

Documentation is available at Head.php

  1. <?php
  2. /**
  3. * Head class file
  4. *
  5. * @author Simon Harris - pointbeing at users.sourceforge.net
  6. * @package PHPTuring
  7. * @version $Id: Head.php,v 1.4 2005/11/15 10:30:40 pointbeing Exp $
  8. */
  9.  
  10. /**
  11. * Head class
  12. *
  13. * @package PHPTuring
  14. */
  15. class Head {
  16.  
  17. /**
  18. * @var int
  19. */
  20. private $position = 0;
  21. /**
  22. * @var Tape
  23. */
  24. private $tape;
  25. /**
  26. * @access public
  27. */
  28. public function __construct()
  29. {
  30. $this->tape = new Tape();
  31. }
  32. /**
  33. * Tells the Head which Tape to use
  34. *
  35. * @access public
  36. * @param Tape $tape
  37. */
  38. public function setTape(Tape $tape)
  39. {
  40. $this->tape = $tape;
  41. }
  42. /**
  43. * Shifts the head one cell left
  44. *
  45. * @access public
  46. */
  47. public function shiftLeft()
  48. {
  49. $this->position--;
  50. }
  51. /**
  52. * Shifts the head one cell right
  53. *
  54. * @access public
  55. */
  56. public function shiftRight()
  57. {
  58. $this->position++;
  59. }
  60. /**
  61. * Returns the current symbol
  62. *
  63. * @access public
  64. * @return int
  65. */
  66. public function read()
  67. {
  68. return $this->tape->read($this->position);
  69. }
  70. /**
  71. * Writes a new value to the current
  72. *
  73. * @access public
  74. * @param int $value
  75. */
  76. public function write($value)
  77. {
  78. $this->tape->write($this->position, $value);
  79. }
  80. }
  81.  
  82.  
  83. ?>

Documentation generated on Tue, 15 Nov 2005 10:37:47 +0000 by phpDocumentor 1.3.0RC3