Created
April 25, 2013 12:40
-
-
Save Bolinha1/5459404 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 ItensVenda | |
{ | |
private $qtd, $itens; | |
public function __construct() | |
{ | |
} | |
public function setQtd($qtd) | |
{ | |
$this->qtd = $qtd; | |
} | |
public function getQtd() | |
{ | |
return $this->qtd; | |
} | |
public function addItens(Produtos $produto) | |
{ | |
$this->itens[] = $produto; | |
} | |
public function getItens() | |
{ | |
return $this->itens; | |
} | |
} |
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 Produtos | |
{ | |
private $nome, $valor; | |
public function __construct($nome, $valor) | |
{ | |
$this->nome = $nome; | |
$this->valor = $valor; | |
} | |
public function getNome() | |
{ | |
return $this->nome; | |
} | |
public function getValor() | |
{ | |
return $this->valor; | |
} | |
} |
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 | |
require 'Produtos.php'; | |
require 'Venda.php'; | |
require 'ItensVenda.php'; | |
$p1 = new Produtos('computador', '2.000,00'); | |
$p2 = new Produtos('impressora', '600,00'); | |
$v1 = new Venda('24/04/2013'); | |
$v1->itens('1', $p1); | |
$v1->itens('2', $p2); | |
var_dump($v1); |
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 Venda | |
{ | |
private $data, $itensVenda; | |
public function __construct($data) | |
{ | |
$this->data = $data; | |
} | |
public function getData() | |
{ | |
return $this->data; | |
} | |
public function itens($qtd,$produto) | |
{ | |
$itens = new ItensVenda(); | |
$itens->setQtd($qtd); | |
$itens->addItens($produto); | |
$this->itensVenda[] = $itens; | |
} | |
public function getItens() | |
{ | |
return $this->itensVenda; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment