Advertisement
joaopaulofcc

Untitled

Jul 26th, 2020
1,377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.67 KB | None | 0 0
  1. class Produto
  2. {
  3.   String editora;
  4.   int quantidade;
  5.   double preco;
  6.  
  7.   // Construtor padrão
  8.   Produto();
  9.   // Construtor alternativo
  10.   Produto.named(this.editora, [this.quantidade = 0, this.preco = 0]);
  11. }
  12.  
  13. class Revista extends Produto
  14. {
  15.   String _nome;
  16.   int _volume;
  17.   int _numero;
  18.  
  19.   Revista(this._nome, this._volume, this._numero);
  20.  
  21.   String get nome
  22.   {
  23.     return _nome;
  24.   }
  25.  
  26.   int get volume
  27.   {
  28.     return _volume;
  29.   }
  30.  
  31.   int get numero
  32.   {
  33.     return _numero;
  34.   }
  35. }
  36.  
  37. void main()
  38. {
  39.   Revista rev1 = Revista("Veja", 23, 3);
  40.   rev1.quantidade = 3;
  41.   print(rev1.quantidade);
  42.   rev1.editora = "Abril";
  43.   print(rev1.editora);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement