From d5d0bb8cf59e7ab18741113e2bd75092fe5c15df Mon Sep 17 00:00:00 2001 From: AliZZZ64 <49293902+AliZZZ64@users.noreply.github.com> Date: Sun, 26 Sep 2021 22:55:34 +0300 Subject: [PATCH 1/2] solution --- bin/dart_application_1.dart | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/bin/dart_application_1.dart b/bin/dart_application_1.dart index 2404519..1b4117e 100644 --- a/bin/dart_application_1.dart +++ b/bin/dart_application_1.dart @@ -17,6 +17,21 @@ class View { } } + +class Text extends View { + String? content; + Text(int id, {this.content, Color? color}) : super(id, color: color); + +// if you want to print content and color even if its null: +/* + @override + String toString() { + return '$id $content $color'; + } +*/ +} + + void main() { /* 1) Create class named `Text` that extends/inherits `View` class, @@ -28,13 +43,21 @@ void main() { */ int id = Random().nextInt(10000); - + var helloText = Text(id, content: "Hello"); print('hello: $helloText'); + task2(); } void task2() { List numbers = List.generate(75, (index) => Random().nextInt(10000)); - + List evenNumbers = []; + + for (int i in numbers) + { + if (i %2 == 0) + evenNumbers.add(i); + } + /* Separate even numbers from the above `numbers` list. List evenNumbers = ... From 2fbf8305263d456fb91aae2e19073743fdf4f9f6 Mon Sep 17 00:00:00 2001 From: AliZZZ64 <49293902+AliZZZ64@users.noreply.github.com> Date: Tue, 28 Sep 2021 13:31:05 +0300 Subject: [PATCH 2/2] commenting the output these are my console outputs , if that's not the correct way to do then inform me please --- bin/dart_application_1.dart | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/dart_application_1.dart b/bin/dart_application_1.dart index 1b4117e..6069b3d 100644 --- a/bin/dart_application_1.dart +++ b/bin/dart_application_1.dart @@ -45,6 +45,9 @@ void main() { int id = Random().nextInt(10000); var helloText = Text(id, content: "Hello"); print('hello: $helloText'); + /* the output will be the following (the id number will be random): + hello : 5384 + */ task2(); } @@ -57,10 +60,9 @@ void task2() { if (i %2 == 0) evenNumbers.add(i); } + print('evenNumbers: $evenNumbers'); - /* - Separate even numbers from the above `numbers` list. - List evenNumbers = ... + /* the output will be the following: + evenNumbers: [List of even numbers] */ - print('evenNumbers: $evenNumbers'); }