<?php
class Rekenen {
public $waarde1;
public $waarde2;
public $operator;
public $wortel;
/*
* $waarde 1: input waarde field 1
* $waarde 2: input waarde field 2
* $operator: +,-, x, :
* $wortel: input waarde wortel
*/
public function setValues($waarde1, $waarde2, $operator){
$this->waarde1 = $waarde1;
$this->waarde2 = $waarde2;
$this->operator = $operator;
}
public function bereken(){
if($this->operator == "+"){
$totaal = $this->waarde1 + $this->waarde2;
} elseif($this->operator == "-"){
$totaal = $this->waarde1 - $this->waarde2;
} elseif($this->operator == ":"){
$totaal = $this->waarde1 / $this->waarde2;
} elseif($this->operator == "x"){
$totaal = $this->waarde1 * $this->waarde2;
}
return $totaal;
}
}
class Worteltrekken extends Rekenen {
public function getWortelValue($valueWortel){
$this->wortel = $valueWortel;
}
public function showWortel(){
return sqrt($this->wortel);
}
}
show_source(__FILE__);
?>
Voer komma getal in.
Uitkomst wortel: 0