/**
* 面向对象计算器
* 思路:
* 1、面向对象的基本,封装、继承、多太
* 2、父类公用类
* 3、各种运算类
*/
/**
* 基类,运算类
* 只提供基本数据,不参与运算
*/
class Operation {
// 第一个数
public $first_num = 0;
// 第二个数
public $second_num = 0;
/**
* 获取结果,其他类覆盖此方法
* @return double $result
*/
public function getResult() {
$result = 0.00;
return $result;
}
}
/**
* 加法类
*/
class OperationAdd extends Operation {
/**
* 覆盖父类,实现加法算法
*/
public function getResult() {
$result = 0;
return $this->first_num + $this->second_num;
}
}
/**
* 减法类
*
*/
class OperationSub ex