public function add($temp) {
$newNum = $this->num + $temp->num;
if($this->denum == $temp->denum) {
// add two fractions having same denominator
$answer = $newNum . "/" . $this->denum;
} else {
// how to add two fractions having different denominator?
}
return $answer;
}
In other words, how to handle the case of two fractions having different denominators, like:
1/3 + 1/6 = 3/6
or
1/3 + 1/5 = 8/15