Last active
December 16, 2015 09:49
-
-
Save Bolinha1/5415393 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Usuario | |
| { | |
| private $nome; | |
| private $contato; | |
| public function __construct($nome) | |
| { | |
| $this->nome = $nome; | |
| } | |
| public function addContato(Contato $contato) | |
| { | |
| $this->contato = $contato; | |
| } | |
| public function getNome() | |
| { | |
| return $this->nome; | |
| } | |
| } |
This file contains hidden or 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 Contato | |
| { | |
| private $contato; | |
| public function __construct() | |
| { | |
| } | |
| public function setContato($contato) | |
| { | |
| $contato = explode(",", $contato); | |
| $this->contato = $contato; | |
| } | |
| public function getContato() | |
| { | |
| return $this->contato; | |
| } | |
| } |
This file contains hidden or 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 | |
| require 'Usuario.php'; | |
| require 'Contato.php'; | |
| $user = new Usuario('Eduardo Cesar'); | |
| $contato = new Contato(); | |
| $contato->setContato('[email protected], [email protected]'); | |
| $user->addContato($contato); | |
| var_dump($user); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment