Skip to content

Instantly share code, notes, and snippets.

@xTudoS
Last active June 7, 2019 01:43
Show Gist options
  • Save xTudoS/17fe57ee40615f67a2ecb2385f6dfb46 to your computer and use it in GitHub Desktop.
Save xTudoS/17fe57ee40615f67a2ecb2385f6dfb46 to your computer and use it in GitHub Desktop.
Prova POO - Dart
class Cachorro {
String nome, raca, cor, porte;
double peso, altura;
int val;
Cachorro(this.nome, this.raca, this.cor, this.peso, this.altura) {
dynamic porte;
porte = setPorte();
this.val = porte[0];
this.porte = porte[1];
}
List setPorte() {
if (this.peso <= 6 && this.altura <= .33) {
return [0, 'Mini'];
} else if (this.peso <= 15 && this.altura <= .43) {
return [1, 'P'];
} else if (this.peso <= 25 && this.altura <= .6) {
return [2, 'M'];
} else if (this.peso <= 45 && this.altura <= .7) {
return [3, 'G'];
} else if (this.peso <= 90) {
return [4, 'XG'];
} else {
return [null, null];
}
}
}
class Remedio {
String nome, tipo, bula;
double quantidade;
Remedio(this.nome, this.quantidade, this.tipo, this.bula);
double dosagem(var cachorro) {
return (cachorro.val + 1) / 5;
}
}
void main() {
Cachorro c1 = Cachorro('Dog', 'A', 'B', 1, .6);
Cachorro c2 = Cachorro('Dog2', 'C', 'D', 9, .3);
if (c1.val < c2.val) {
print('${c2.nome} possui o maior porte');
} else if (c1.val > c2.val) {
print('${c1.nome} possui o maior porte');
} else {
print('${c1.nome} e ${c2.nome} possuem o mesmo porte');
}
print('${"-" * 10}');
Remedio r = Remedio('A', 10, 'C', 'K');
print('Dosagem para ${c1.nome}: ${r.dosagem(c1)}');
print('Dosagem para ${c2.nome}: ${r.dosagem(c2)}');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment