All pastes #420152 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-04-01 22:20 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
{
  var $num3;
  
  function __construct()
  {
   	$this->num3 = $this->num1 + $this->num2;
    echo "$this->num1 plus $this->num2 equals $this->num3<br />";
  }
}

class subCalc extends baseCalc
{
    var $num3;
    
    function __construct()
    {
    	$this->num3 = $this->num1 - $this->num2;
  		echo "$this->num1 minus $this->num2 equals $this->num3<br />";
  	}
}

class mulCalc extends baseCalc
{
 	var $num3;
 	
 	function __construct()
 	{
 		$this->num3 = $this->num1 * $this->num2;
 		echo "$this->num1 times $this->num2 equals $this->num3<br />";
 	}
}

class divCalc extends baseCalc
{
  var $num3;
  
  function __construct()
  {
  	$this->num3 = $this->num1 / $this->num2;
		echo "$this->num1 divided by $this->num2 equals $this->num3<br />";
	}
}

$object1 = new baseCalc();
$object1 -> calculate();
$object2 = new addCalc();
$object2 -> addCalc();

?>