function roll() { $result = 0; for ($i = 0; $i < $this->numberOfDices; $i++) { $result += RandomNumber::get() % $this->numberOfDots + 1; } return $result + $this->adjustment; }
public function test1() { $low = 10; $hi = 20; $d = RandomNumber::getInRange($low, $hi); $this->assertGreaterThanOrEqual($low, $d); $this->assertLessThanOrEqual($hi, $d); }
public function testGenerate() { $generator = new RandomNumber(0, 3); $this->assertContains($generator->generate(), array(0, 1, 2, 3)); $this->assertContains($generator->generate(), array(0, 1, 2, 3)); $this->assertContains($generator->generate(), array(0, 1, 2, 3)); $this->assertContains($generator->generate(), array(0, 1, 2, 3)); $this->assertContains($generator->generate(), array(0, 1, 2, 3)); }
<?php require('random/RandomNumber.php'); echo RandomNumber::getRandomNumber(37)-1; ?>
<?php include('RandomNumber.php'); echo RandomNumber::getRandomNumber(36); ?>