3 lab
This commit is contained in:
parent
a985380108
commit
f2c5bbb806
53
lab2.java
53
lab2.java
@ -1,53 +0,0 @@
|
||||
enum FurLength { none, short, medium, long }
|
||||
|
||||
extension FurLengthPrint on FurLength {
|
||||
String prints() {
|
||||
switch (this) {
|
||||
case FurLength.none:
|
||||
return ('нет шерсти');
|
||||
case FurLength.short:
|
||||
return('короткая');
|
||||
case FurLength.medium:
|
||||
return('средняя');
|
||||
case FurLength.long:
|
||||
return('длинная');
|
||||
default:
|
||||
return ('нет данных');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Cat {
|
||||
final String _name;
|
||||
final int _lifeSpan;
|
||||
final FurLength _furLength;
|
||||
|
||||
String get name => _name;
|
||||
int get lifeSpan => _lifeSpan;
|
||||
String get furLength => _furLength.prints();
|
||||
|
||||
Cat(this._name, this._lifeSpan, this._furLength);
|
||||
}
|
||||
|
||||
void main() {
|
||||
print("Энкциклопедия кошек загружена");
|
||||
|
||||
final listCats = [
|
||||
new Cat("Сфинкс", 13, FurLength.none),
|
||||
new Cat("Персидская", 20, FurLength.long),
|
||||
new Cat("Сиамская", 23, FurLength.short),
|
||||
];
|
||||
|
||||
for (final cat in listCats)
|
||||
{
|
||||
print("Порода: ${cat.name} \t Продолжительность жизни: ${cat.lifeSpan-3}-${cat.lifeSpan} \t Длина шерсти: ${cat.furLength})");
|
||||
}
|
||||
|
||||
Future<void> future = Future.delayed(
|
||||
Duration(seconds: 1),
|
||||
() => print("Сохранение данных"));
|
||||
|
||||
future.then((_) {
|
||||
print("Закрытие приложения");
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user