Created
March 20, 2014 18:08
-
-
Save davidchc/9670173 to your computer and use it in GitHub Desktop.
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 ContaBancaria{ | |
private $saldo; | |
public function __construct($saldo){ | |
$this->saldo = $saldo; | |
} | |
public function depositar($valor){ | |
$this->saldo += $valor; | |
} | |
public function retirar($valor){ | |
if($this->saldo >= $valor){ | |
$this->saldo -= $valor; | |
} | |
} | |
public function saldoAtual(){ | |
return $this->saldo; | |
} | |
} | |
$conta = new ContaBancaria(2000); | |
echo 'Valor na Conta : '.$conta->saldoAtual(); | |
$conta->depositar(200); | |
echo 'Após o Depósito : '.$conta->saldoAtual(); | |
$conta->retirar(10); | |
echo 'Após a Retirada : '.$conta->saldoAtual(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment