Created
November 23, 2020 18:50
-
-
Save internetova/e1fb77ad3765f86fbf0529eb439933c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Задание 1 | |
Есть классы геометрических фигур - наследники Shape и класс страны - Country. | |
Эти классы хранят массив borders - в контексте фигур это количество граней фигуры, | |
а в контексте стран - это количество границ. | |
Требуется: | |
Реализовать миксин BorderHelper, который подмешивает в класс возможность вычисления | |
количества граней/границ. Вызов должен происходить следующим образом | |
Shape([1,2,3]).getBorderCount(); | |
*/ | |
mixin BorderHelper { | |
List<double> bordersList = []; | |
void getBorderCount() => print('количество границ ${bordersList.length}'); | |
} | |
class Shape with BorderHelper { | |
Shape(this.borders) { | |
bordersList = borders; | |
} | |
final List<double> borders; | |
} | |
class Trapezoid extends Shape { | |
Trapezoid() : super([8.0, 5.0, 10.0, 5.0]) { | |
bordersList = borders; | |
} | |
} | |
class Country with BorderHelper { | |
Country(this.borders) { | |
bordersList = borders; | |
} | |
final List<double> borders; | |
} | |
void main() { | |
Shape([1, 2, 3, 4]).getBorderCount(); | |
Trapezoid().getBorderCount(); | |
Country([1, 2, 3]).getBorderCount(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment