Source for file Program.php

Documentation is available at Program.php

  1. <?php
  2. /**
  3. * Program class file
  4. *
  5. * @author Simon Harris - pointbeing at users.sourceforge.net
  6. * @package PHPTuring
  7. * @version $Id: Program.php,v 1.3 2005/11/15 10:30:40 pointbeing Exp $
  8. */
  9.  
  10. /**
  11. * Program class
  12. *
  13. * @package PHPTuring
  14. */
  15. class Program {
  16.  
  17. /**
  18. * @var array
  19. */
  20. private $instructions = array();
  21. /**
  22. * Adds an Instruction to the Program
  23. *
  24. * @access public
  25. * @param Instruction $inst
  26. */
  27. public function addInstruction(Instruction $inst)
  28. {
  29. $this->instructions[] = $inst;
  30. }
  31.  
  32. /**
  33. * Returns the Instruction to follow given state and read value
  34. *
  35. * @access public
  36. * @param string $state
  37. * @param char $read_val
  38. * @return Instruction
  39. */
  40. public function getInstruction($state, $read_val)
  41. {
  42. foreach ($this->instructions as $inst) {
  43. if ( ($inst->getInitialState() == $state) && ($inst->getPrerequisite() == $read_val) ) {
  44. return $inst;
  45. }
  46. }
  47. return FALSE;
  48. }
  49. }
  50.  
  51.  
  52. ?>

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