Exemplo n.º 1
0
 public function runMath($value)
 {
     $calc = new Calculator();
     $calc->setValue($value[1], $value[3]);
     $result = "";
     if ($value[2] == iCalc::iMathSignalPlus) {
         $result = $calc->getPlus();
     } else {
         if ($value[2] == iCalc::iMathSignalDivi) {
             $result = $calc->getDivide();
         } else {
             if ($value[2] == iCalc::iMathSignalMulti) {
                 $result = $calc->getMultiply();
             } else {
                 if ($value[2] == iCalc::iMathSignalMinus) {
                     $result = $calc->getMinus();
                 } else {
                     if ($value[2] == iCalc::iMathSignalModu) {
                         $result = $calc->getModule();
                     } else {
                         $result = iCalc::iHelpMessage;
                     }
                 }
             }
         }
     }
     return $result;
 }
Exemplo n.º 2
0
<?php

require_once "Calculator.class.php";
$Calc = new Calculator();
for ($a = 0; $a < 10; $a++) {
    echo $a . "+" . $a . "=" . $Calc->getPlus($a);
    echo $a . "*" . $a . "=" . $Calc->getMal($a);
    echo $a . "! =" . $Calc->getFak($a);
    echo "<hr/>";
}