Skip to content

Commit

Permalink
Implementação de um método estático.
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrique committed Feb 9, 2020
1 parent 6509742 commit ad0def7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion banco.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
$segundaConta = new Conta('789.345.302-23', 'Gustavo');
var_dump($segundaConta);

echo Conta::$numeroDeContas;
echo Conta::$recuperarNumeroDeContas . PHP_EOL;
6 changes: 5 additions & 1 deletion src/Conta.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Conta {
private $cpfTitular;
private $nomeTitular;
private $saldo;
public static $numeroDeContas = 0;
private static $numeroDeContas = 0;

//Construtor
/*Para acessarmos um atributo estático, temos de chamá-lo da seguinte forma:
Expand Down Expand Up @@ -74,4 +74,8 @@ private function validaNomeTitular(string $nomeTitular): void {
exit();
}
}

public static function recuperaNumeroDeContas(): int {
return Conta::$numeroDeContas;
}
}

0 comments on commit ad0def7

Please sign in to comment.