From 6ecb2d21efeae7b09d929a9e8ec1ae49a6973881 Mon Sep 17 00:00:00 2001 From: Selfishmachine <91218301+Selfishmachine@users.noreply.github.com> Date: Sat, 25 Sep 2021 22:38:25 +0300 Subject: [PATCH 1/3] Haider Saadoun's code --- bin/dart_application_1.dart | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/bin/dart_application_1.dart b/bin/dart_application_1.dart index 2404519..4e73886 100644 --- a/bin/dart_application_1.dart +++ b/bin/dart_application_1.dart @@ -1,43 +1,39 @@ import 'dart:math'; - class Color { Color(this.value); final int value; } - class View { int id; Color? color; - View(this.id, {this.color}); - @override String toString() { 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: - 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); + + Text 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)); + + List evenNumbers = numbers.where((element) => element.isEven).toList(); - /* - Separate even numbers from the above `numbers` list. - List evenNumbers = ... - */ print('evenNumbers: $evenNumbers'); } From f4c93732128de47a90dbb5ed8f18deaf09174815 Mon Sep 17 00:00:00 2001 From: Selfishmachine <91218301+Selfishmachine@users.noreply.github.com> Date: Sat, 25 Sep 2021 22:41:10 +0300 Subject: [PATCH 2/3] Haider Saadoun's code --- bin/dart_application_1.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/dart_application_1.dart b/bin/dart_application_1.dart index 4e73886..97746c1 100644 --- a/bin/dart_application_1.dart +++ b/bin/dart_application_1.dart @@ -33,7 +33,12 @@ void main() { void task2() { List numbers = List.generate (75, (index) => Random().nextInt(10000)); - List evenNumbers = numbers.where((element) => element.isEven).toList(); + List evenNumbers=[]; + for(final i in numbers){ + if (i.isEven){ + evenNumbers.add(i); + } + } print('evenNumbers: $evenNumbers'); } From 7af9f46248c68dcd767880bfa9090e509bee9401 Mon Sep 17 00:00:00 2001 From: haider sadoon <91218301+Selfishmachine@users.noreply.github.com> Date: Wed, 29 Sep 2021 00:06:29 +0300 Subject: [PATCH 3/3] 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 97746c1..f9b0ad4 100644 --- a/bin/dart_application_1.dart +++ b/bin/dart_application_1.dart @@ -42,3 +42,8 @@ void task2() { print('evenNumbers: $evenNumbers'); } + + +// the outputs +//hello: 6916 +//evenNumbers: [6342, 7222, 8470, 4018, 9540, 1742, 4472, 8654, 5008, 1376, 1210, 9752, 8550, 6006, 5674, 6224, 8680, 3442, 1588, 4494, 3604, 4036, 4162, 7458, 9768, 204, 3334, 9726, 7984, 9354, 9276, 2442, 6668]