コード例 #1
0
ファイル: function.php プロジェクト: soycaringal/gae-test
 public function testError()
 {
     $math = new Math();
     // no input
     try {
         $math->add();
     } catch (\Exception $e) {
         $this->assertEquals('Please provide numbers to add', $e->getMessage());
     }
     // no input
     try {
         $math->subtract();
     } catch (\Exception $e) {
         $this->assertEquals('Please provide numbers to subtract', $e->getMessage());
     }
     // no input
     try {
         $math->multiply();
     } catch (\Exception $e) {
         $this->assertEquals('Please provide numbers to multiply', $e->getMessage());
     }
     // no input
     try {
         $math->divide();
     } catch (\Exception $e) {
         $this->assertEquals('Please provide numbers to divide', $e->getMessage());
     }
     //invalid input
     try {
         $math->setA('adf');
     } catch (\Exception $e) {
         $this->assertEquals('Invalid input', $e->getMessage());
     }
 }
コード例 #2
0
ファイル: PhysicShot.php プロジェクト: Gritch69/XG-Project
 /**
  * PhysicShot::start()
  * Start the system
  * @return
  */
 public function start()
 {
     //se il danno è zero non serve.
     if ($this->damage == 0) {
         return;
     }
     //se gli scudi sono disattivati,per evitare la divisione per zero
     if ($this->fighters->getShieldCellValue() == 0) {
         $this->inflict();
         return;
     }
     $currentCellsCount = $this->fighters->getCurrentShield();
     if (USE_HITSHIP_LIMITATION) {
         // bisogna tenere solo i colpi neccessari alla distruzione di tutti gli scudi
         $currentCellsCount = floor($currentCellsCount * $this->getHitShips() / $this->fighters->getCount());
     }
     $dv = Math::divide(new Number($this->damage), new Number($this->fighters->getShieldCellValue()), true);
     $cellsDestroyedInOneShot = $dv->result;
     $bouncedDamageForOneShot = $dv->rest;
     echo "cellvalue=" . $this->fighters->getShieldCellValue() . "<br>cellsDestroyedInOneShot={$cellsDestroyedInOneShot}<br>bouncedDamageForOneShot={$bouncedDamageForOneShot}<br>currentCellsCount={$currentCellsCount}<br>";
     $this->bounce($currentCellsCount, $cellsDestroyedInOneShot, $bouncedDamageForOneShot);
     $this->assorb($currentCellsCount, $cellsDestroyedInOneShot);
     $this->inflict();
 }
コード例 #3
0
ファイル: Fire.php プロジェクト: athk/XG-Proyect-v3.x.x
 public function getShotsFiredByAllToOne($real = false)
 {
     $num = new Number($this->getAttackerTotalShots());
     $denum = new Number($this->defenderFleet->getTotalCount());
     return Math::divide($num, $denum, $real);
 }