From f5057eb50dc96362ffdd05dfda01301c9a49060f Mon Sep 17 00:00:00 2001 From: Fahad Hayan <90945910+Fahad-Hayan@users.noreply.github.com> Date: Sat, 25 Sep 2021 13:12:39 +0300 Subject: [PATCH 1/3] Update dart_application_1.dart This is my commitment to fix this Dart code I hope it's right Many Thanks Fahad Hayan --- bin/dart_application_1.dart | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bin/dart_application_1.dart b/bin/dart_application_1.dart index 2404519..1cf2032 100644 --- a/bin/dart_application_1.dart +++ b/bin/dart_application_1.dart @@ -16,28 +16,36 @@ 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. - Here is the Text constuctor: + Here is the Text constructor: Text(int id, this.content, {Color? color}) : super(id, color: color) 2) Create new `Text` object with the following: var helloText = Text(, content: 'Hello' ) */ int id = Random().nextInt(10000); - + var helloText = Text(id, "Fahad Hayan"); print('hello: $helloText'); } void task2() { List numbers = List.generate(75, (index) => Random().nextInt(10000)); - + List evenNumbers=[]; /* Separate even numbers from the above `numbers` list. List evenNumbers = ... */ + for (final i in numbers) { + if (i.isEven) { + evenNumbers.add(i); + } + } print('evenNumbers: $evenNumbers'); } From d6cfdcf1897c3771bc02eb68cac52fadcf78590c Mon Sep 17 00:00:00 2001 From: Fahad Hayan <90945910+Fahad-Hayan@users.noreply.github.com> Date: Sat, 25 Sep 2021 18:11:37 +0300 Subject: [PATCH 2/3] Update dart_application_1.dart --- bin/dart_application_1.dart | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/bin/dart_application_1.dart b/bin/dart_application_1.dart index 1cf2032..6f43814 100644 --- a/bin/dart_application_1.dart +++ b/bin/dart_application_1.dart @@ -22,29 +22,30 @@ class Text extends View { } void main() { /* - 1) Create class named `Text` that extends/inherits `View` class, - and has a `String content` property. + 1) Create class named Text that extends/inherits View class, + and has a String content property. Here is the Text constructor: Text(int id, this.content, {Color? color}) : super(id, color: color) - 2) Create new `Text` object with the following: + 2) Create new Text object with the following: var helloText = Text(, content: 'Hello' ) */ int id = Random().nextInt(10000); var helloText = Text(id, "Fahad Hayan"); print('hello: $helloText'); + task2(); } void task2() { List numbers = List.generate(75, (index) => Random().nextInt(10000)); - List evenNumbers=[]; + List evenNumbers=[]; /* - Separate even numbers from the above `numbers` list. + Separate even numbers from the above numbers list. List evenNumbers = ... */ - for (final i in numbers) { - if (i.isEven) { - evenNumbers.add(i); + for (var i=0;i Date: Tue, 28 Sep 2021 16:58:13 +0300 Subject: [PATCH 3/3] Update dart_application_1.dart just an update contains comments about how the final output on the console will look like --- bin/dart_application_1.dart | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/dart_application_1.dart b/bin/dart_application_1.dart index 6f43814..371b774 100644 --- a/bin/dart_application_1.dart +++ b/bin/dart_application_1.dart @@ -32,8 +32,8 @@ void main() { int id = Random().nextInt(10000); var helloText = Text(id, "Fahad Hayan"); - print('hello: $helloText'); - task2(); + print('hello: $helloText'); //The Output will be: hello: 4823 + task2(); //Here we call the function task2 } void task2() { @@ -48,5 +48,11 @@ void task2() { evenNumbers.add(numbers[i]); } } - print('evenNumbers: $evenNumbers'); + print('evenNumbers: $evenNumbers'); // The Output will be: evenNumbers: [4398, 9538, 4348, 5618, 9276, 2738, 3534, 8176, 624, 6812, 8654, 1398, 8494, 7002, 556, 7654, 6450, 4910, 8928, 8220, 8544, 5956, 5950, 3258, 6218, 7574, 1852, 5522, 24, 8660, 5952, 684, 1700, 4900, 9620, 234, 4656, 1066, 1806] } +/* +The final result of output in the console will be like that: + +hello: 4823 +evenNumbers: [4398, 9538, 4348, 5618, 9276, 2738, 3534, 8176, 624, 6812, 8654, 1398, 8494, 7002, 556, 7654, 6450, 4910, 8928, 8220, 8544, 5956, 5950, 3258, 6218, 7574, 1852, 5522, 24, 8660, 5952, 684, 1700, 4900, 9620, 234, 4656, 1066, 1806] +*/