Advertisement
pedro1414

Untitled

Sep 15th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <?php
  2. echo "<h2>Competencia 3</h2><br>";
  3. class Livro{
  4. public $nome;
  5. public $tempo;
  6. public $valor;
  7. public $valoremp;
  8. public $autor;
  9. function __construct($nome, $tempo, $valor, $autor)
  10. {
  11. $this->nome = $nome;
  12. $this->tempo = $tempo;
  13. $this->valor = $valor;
  14. $this->autor = $autor;
  15. $this->valoremp = $this->calcularvaloremp();
  16. }
  17. function calcularvaloremp()
  18. {
  19. return round($this->tempo * $this->valor,5);
  20. }
  21. }
  22. $Livros = array(0);
  23. $Livros[0] = new Livro("<b>Livro 1</b>", 30, 0.50, 'ze');
  24. $Livros[1] = new Livro("<b>Livro 2</b>", 60, 0.30,'maria');
  25. $Livros[2] = new Livro("<b>Livro 3</b>", 45, 0.40,'andre');
  26. $Livros[3] = new Livro("<b>Livro 4</b>", 20, 0.60,'douglas');
  27. for($i = 0; $i < count($Livros); $i++)
  28. {
  29. $func = $Livros[$i];
  30. $valort = $Livros[$i];
  31. $valor = $Livros[$i];
  32. $tempo = $Livros[$i];
  33. $autoral = $Livros[$i];
  34. echo "Nome do livro: $func->nome<br>";
  35. echo "Autor: $autoral->autor<br>";
  36. echo "Custo diario: R$ $valor->valor<br>";
  37. echo "Tempo emprestado: $tempo->tempo Dias<br>";
  38. echo "Valor total do emprestimo: R$ $valort->valoremp <br>";
  39. echo "---------------------------------------------------<br>";
  40. }
  41.  
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement