From 04b4ed2d0c6e0ae2a32f0d8c3bb2caf6dcfccf51 Mon Sep 17 00:00:00 2001 From: Abdullah <90783453+3b00dy@users.noreply.github.com> Date: Sun, 26 Sep 2021 15:10:05 +0300 Subject: [PATCH 1/2] Dart Task --- bin/dart_application_1.dart | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/bin/dart_application_1.dart b/bin/dart_application_1.dart index 2404519..dc6fe63 100644 --- a/bin/dart_application_1.dart +++ b/bin/dart_application_1.dart @@ -17,27 +17,26 @@ class View { } } -void main() { - /* - 1) Create class named `Text` that extends/inherits `View` class, - and has a `String content` property. - Here is the Text constuctor: - Text(int id, this.content, {Color? color}) : super(id, color: color) - 2) Create new `Text` object with the following: - var helloText = Text(, content: 'Hello' ) - */ +class Text extends View { + String content; + Text(int id, this.content, {Color? color}) : super(id, color: color); +} +void main() { int id = Random().nextInt(10000); - + var helloText = Text(id, 'Hello'); print('hello: $helloText'); } void task2() { - List numbers = List.generate(75, (index) => Random().nextInt(10000)); - - /* - Separate even numbers from the above `numbers` list. - List evenNumbers = ... - */ + List numbers = + List.generate(75, (index) => Random().nextInt(10000)); + List evenNumbers = []; + for (var i = 0; i < numbers.length; i++) { + if (numbers[i].isEven) { + evenNumbers.add(numbers[i]); + } + ; + } print('evenNumbers: $evenNumbers'); } From f8ccd2eb65670c62e6fbe755f21d45bf8611ebbf Mon Sep 17 00:00:00 2001 From: Abdullah <90783453+3b00dy@users.noreply.github.com> Date: Tue, 28 Sep 2021 15:46:28 +0300 Subject: [PATCH 2/2] Update dart_application_1.dart --- bin/dart_application_1.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bin/dart_application_1.dart b/bin/dart_application_1.dart index dc6fe63..e6ef681 100644 --- a/bin/dart_application_1.dart +++ b/bin/dart_application_1.dart @@ -26,6 +26,8 @@ void main() { int id = Random().nextInt(10000); var helloText = Text(id, 'Hello'); print('hello: $helloText'); + //console output {hello: 2353} this number will be change after every eun because it's random number + } void task2() { @@ -39,4 +41,7 @@ void task2() { ; } print('evenNumbers: $evenNumbers'); + //this function will show the output only when call it in main function + //Console output + //evenNumbers: [3358, 2752, 524, 2528, 736, 4464, 3546, 8026, 2732, 5556, 5042, 746, 1728, 7732, 7952, 2166, 4750, 420, 136, 3280, 6756, 6538, 3618, 6884, 9830, 1796, 618, 7304, 1566, 8920, 9736, 7566, 6886, 3024, 9592, 2640, 3384] }