Skip to content

Instantly share code, notes, and snippets.

@al-the-x
Created July 5, 2011 21:39
Show Gist options
  • Save al-the-x/1066030 to your computer and use it in GitHub Desktop.
Save al-the-x/1066030 to your computer and use it in GitHub Desktop.
OrlandoPHP Coding Dojo -- Jun 18, 2011
<?php
/**
* 0 = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 . . . ];
* 1 = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 . . . ];
* 2 = [ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 . . . ];
* 3 = [ 1, 0, 0, 0, 1, 1, 1, 0, 0, 0 . . . ];
* 4 = [ 1, 0, 0, 1, 1, 1, 1, 1, 0, 0 . . . ];
* 5 = [ . . . ];
* . . .
* 100 = [ ??? ];
*/
class Doors
{
function __construct()
{
$this->current_state = array();
foreach( range(1, 100) as $step )
{
$this->current_state[$step] = 0;
}
}
function state ( )
{
return $this->current_state();
}
function take_pass($passNumber){
foreach( range(1, 100) as $step ) $this->current_state[$step] = 1;
return $this->current_state;
}
}
<?php
require_once 'main.php';
class Test extends PHPUnit_Framework_TestCase
{
function setUp()
{
$this->doors = new Doors();
}
function test_doors_toggle_pass_one()
{
$current_state = array();
foreach( range(1, 100) as $step ) $current_state[$step] = 1;
$this->assertEquals($current_state, $this->doors->take_pass(1));
}
function test_doors_toggle_pass_two()
{
$this->doors->take_pass(1);
// foreach(range(1,100) as $step) $current_State
// $this->assertEquals($current_state, $this->doors->take_pass(2););
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment