Advertisement
joaopaulofcc

Untitled

Jul 27th, 2020
1,532
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.02 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.   String get editora
  13.   {
  14.     return _editora;
  15.   }
  16. }
  17.  
  18. class Revista extends Produto
  19. {
  20.   String _nome;
  21.   int _volume;
  22.   int _numero;
  23.  
  24.   Revista(String nome, int volume, int numero, String editora) : super.named(editora)
  25.   {
  26.     this._nome = nome;
  27.     this._volume = volume;
  28.     this._numero = numero;
  29.   }
  30.  
  31.   String get nome
  32.   {
  33.     return _nome;
  34.   }
  35.  
  36.   int get volume
  37.   {
  38.     return _volume;
  39.   }
  40.  
  41.   int get numero
  42.   {
  43.     return _numero;
  44.   }
  45. }
  46.  
  47. void main()
  48. {
  49.   Revista rev1 = Revista("Veja", 23, 3, "Abril");
  50.   rev1.quantidade = 3;
  51.     rev1.preco = 10.50;
  52.        
  53.     print("Nome: ${rev1.nome}");
  54.     print("Volume: ${rev1.volume}");
  55.     print("Numero: ${rev1.numero}");
  56.     print("Editora: ${rev1.editora}");
  57.     print("Quantidade: ${rev1.quantidade}");
  58.     print("PreΓ§o: ${rev1.preco}");
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement