All pastes #420153 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-04-01 22:21 UTC
rendered paste body
<?php
class baseCalc{
  var $num1 = 5;
  var $num2 = 6;
    function calculate() {
    echo "$this->num1 is the first number<br />";
    echo "$this->num2 is the second number<br />";
    }
  }
  class addCalc extends baseCalc {
    function add() {
    var $num3 = $num1 + $num2;
    echo "$this->num1 plus $this->num2 equals $this->num3<br />";
    }
  }
  class subCalc extends baseCalc {
    function subtract() {
    var $num3 = $num1 - $num2;
    echo "$this->num1 minus $this->num2 equals $this->num3<br />";
    }
  }
  class mulCalc extends baseCalc {
    function multiply() {
    var $num3 = $num1 * $num2;
    echo "$this->num1 times $this->num2 equals $this->num3<br />";
    }
  }
  class divCalc extends baseCalc {
    function divide() {
    var $num3 = $num1 / $num2;
    echo "$this->num1 divided by $this->num2 equals $this->num3<br />";
    }
  }
$object1 = new baseCalc();
$object1 -> calculate();
$object2 = new addCalc();
$object2 -> add();

?>