diff --git a/bin/dart_application_1.dart b/bin/dart_application_1.dart index 2404519..cebcef1 100644 --- a/bin/dart_application_1.dart +++ b/bin/dart_application_1.dart @@ -16,8 +16,16 @@ class View { return '$id'; } } +class Text extends View{ + String content ; + Text(int id , this.content , {Color? color } ) : super (id, color : color ){ + + } +} void main() { + + /* 1) Create class named `Text` that extends/inherits `View` class, and has a `String content` property. @@ -28,16 +36,37 @@ void main() { */ int id = Random().nextInt(10000); + + var helloText = Text(id , "Hello"); + + print('hello: $helloText'); + task2(); } void task2() { - List numbers = List.generate(75, (index) => Random().nextInt(10000)); + List numbers = + List + .generate(75, (index) => Random() + .nextInt(10000)); /* Separate even numbers from the above `numbers` list. List evenNumbers = ... */ + + List evenNumbers = + numbers + .where((x) => x % 2 == 0 ) + .toList() ; + print('evenNumbers: $evenNumbers'); } + + +// result of console + +// hello: 4899 +// evenNumbers: [3822, 14, 6304, 1408, 6482, 9932, 8500, 3996, 6544, 5784, 6798, 3778, 5652, 214, 6546, 1820, 3312, 8790, 5060, 86, 3026, 9346, 3882, 3032, 306, 3840, 1304, 2296, 3672, 4418, 4104, 8886, 1112, 6438] +