Skip to content

Instantly share code, notes, and snippets.

@andersonFaro9
Last active December 16, 2015 03:49
Show Gist options
  • Save andersonFaro9/5372760 to your computer and use it in GitHub Desktop.
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
<?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