Created
June 6, 2012 21:09
-
-
Save imjacobclark/2884780 to your computer and use it in GitHub Desktop.
OOP Calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Calc{ | |
public $input; | |
public $input2; | |
public $output; | |
function setInput($int){ | |
$this->input = (int) $int; | |
} | |
function setInput2($int){ | |
$this->input2 = (int) $int; | |
} | |
function Calculate(){ | |
$this->output = $this->input + $this->input2; | |
} | |
function getResult(){ | |
return $this->output; | |
} | |
} | |
$calc = new Calc(); | |
$calc->setInput(5); | |
$calc->setInput2(22); | |
$calc->Calculate(); | |
echo $calc->getResult(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment