From f2c5bbb806b054cf948c8e0514bcfab872fd2712 Mon Sep 17 00:00:00 2001 From: dex_moth Date: Tue, 12 Nov 2024 22:48:38 +0400 Subject: [PATCH] 3 lab --- lab2.java | 53 ----------------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 lab2.java diff --git a/lab2.java b/lab2.java deleted file mode 100644 index 95d032a..0000000 --- a/lab2.java +++ /dev/null @@ -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 future = Future.delayed( - Duration(seconds: 1), - () => print("Сохранение данных")); - - future.then((_) { - print("Закрытие приложения"); - }); -} \ No newline at end of file