Last active
December 16, 2015 03:49
-
-
Save andersonFaro9/5372760 to your computer and use it in GitHub Desktop.
Aproveitando o polimorfismo e deixando o codigo mais elegante, evitando o uso de muitos if's e else's
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 | |
ini_set('display', 'On'); | |
error_reporting('E_ALL','STRICT'); | |
interface Salario | |
{ | |
function mostrarSalario(); | |
} | |
interface maiorSalario | |
{ | |
function mostraroMaiorSalario(); | |
} | |
class Professor implements Salario | |
{ | |
public function mostrarSalario() | |
{ | |
return "R$ 1.100.00 <br/>"; | |
} | |
} | |
class Diretor implements Salario, maiorSalario | |
{ | |
public function mostrarSalario() | |
{ | |
return "R$ 1.700.00 <br/>"; | |
} | |
public function mostraroMaiorSalario() | |
{ | |
return mostrarSalario(); | |
} | |
} | |
$Professor = new Professor(); | |
echo "Salário do professor ". $Professor->mostrarSalario(); | |
$diretor = new Diretor(); | |
echo "Salário do diretor ".$diretor->mostrarSalario(); | |
echo "<b>Maior salário</b> ".$diretor->mostrarSalario()."--><b> Diretor<b></b>"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment