Advertisement
joaopaulofcc

Untitled

Jul 25th, 2020
1,856
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.82 KB | None | 0 0
  1. class Pessoa
  2. {
  3.   String _nome;
  4.   double _peso;
  5.   double _altura;
  6.  
  7.   String get nome
  8.   {
  9.     return _nome;
  10.   }
  11.  
  12.   set nome(String nome)
  13.   {
  14.     this._nome = nome;
  15.   }
  16.  
  17.   double get peso
  18.   {
  19.     return _peso;
  20.   }
  21.  
  22.   set peso(double peso)
  23.   {
  24.     this._peso = peso;
  25.   }
  26.  
  27.   double get altura
  28.   {
  29.     return _altura;
  30.   }
  31.  
  32.   set altura(double altura)
  33.   {
  34.     this._altura = altura;
  35.   }
  36.  
  37.   Pessoa(this._peso, this._altura, this._nome);
  38. }
  39.  
  40.  
  41. void main()
  42. {
  43.   Pessoa p1 = new Pessoa(82.0, 1.65, "Carlos");
  44.  
  45.   print("Nome: ${p1.nome ?? "sem nome"}");
  46.   print("Peso: ${p1.peso} kg");
  47.   print("Altura: ${p1.altura} m\n");
  48.  
  49.   Pessoa p2 = Pessoa(95.0, 1.78, "Kleber");
  50.  
  51.   print("Nome: ${p2.nome ?? "sem nome"}");
  52.   print("Peso: ${p2.peso} kg");
  53.   print("Altura: ${p2.altura} m");
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement