Simple Calculator
quotient
with exception test
public function quotient()
{
if( $this->a == 0 ) {
throw new Exception( 'division by zero' );
}
return $this->a / $this->b;
}
Math.Calculator |
a |
b |
quotient() |
4 |
2 |
2 |
9 |
0 |
division by zero |
4 |
0 |
2 |
6 |
3 |
2 |
21 |
7 |
3 |
9 |
6 |
1.5 |
12 |
3 |
4 |
2 |
2 |
1 |
10 |
5 |
1.9 |
sum
public function sum()
{
return $this->a + $this->b;
}
Math.Calculator |
a |
b |
sum() |
2 |
2 |
4 |
6 |
2 |
9 |
sub
public function sub()
{
return $this->a - $this->b;
}
Math.Calculator |
a | b | sub() |
2 | 2 | 1 |
2 | 4 | -2 |
This document implements Ward Cunningham's FIT examples