コード例 #1
0
ファイル: consoleinput.php プロジェクト: mspaeth/GameOfLife
 /**
  * The constructor asks for the width and height of the gamefield to create it in the parent constructor.
  *
  * @param array|null $_config No config is needed here.
  */
 public function __construct(array $_config = null)
 {
     echo "Please enter the width of the gamefield\n";
     $this->width = stream_get_line(STDIN, 1024, PHP_EOL);
     echo "Please enter the height of the gamefield\n";
     $this->height = stream_get_line(STDIN, 1024, PHP_EOL);
     parent::__construct($_config);
 }
コード例 #2
0
 /**
  * @since  2014-05-10
  * @author Patrick Forget <*****@*****.**>
  */
 protected static function getDefaultValues()
 {
     static $defaultValues = null;
     if ($defaultValues === null) {
         $defaultValues = array_merge(parent::getDefaultValues(), array('choices' => array()));
     }
     //if
     return $defaultValues;
 }
コード例 #3
0
ファイル: txtinput.php プロジェクト: mspaeth/GameOfLife
 /**
  * The constructor opens the txt file and calls the parent constructor to create the gamefield and set the cells.
  *
  * @param array|null $_config Config array which should contain in this context at least the filepath to the txt file, which we need for creating a GameField.
  */
 public function __construct(array $_config = null)
 {
     if (isset($_config)) {
         $this->file = $_config['filePath'];
         $linecount = 0;
         $handle = fopen($this->file, "r");
         while (!feof($handle)) {
             $line = fgets($handle);
             if (empty($this->width)) {
                 $this->width = strlen($line) - 2;
             }
             $linecount++;
         }
         $this->height = $linecount - 1;
         fclose($handle);
         parent::__construct($_config);
     } else {
         die("Error can't find txt file, please use --filepath 'path to file'");
     }
 }
コード例 #4
0
 /**
  * コンストラクタ
  *
  * @param array $params 入力パラメータ
  */
 function __construct($params = null)
 {
     parent::__construct($params);
 }
コード例 #5
0
 function EnumInput($name, $possibilities)
 {
     parent::BaseInput($name);
     $this->_poss = $possibilities;
 }