diff --git a/README.md b/README.md index 2b28a92..5d9ebda 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -### Guide -Fork this repo, and add/fix the missing code in [/bin/dart_application_1.dart](/bin/dart_application_1.dart) -To be fixed errors +Added/fixed the missing code in [/bin/dart_application_1.dart](/bin/dart_application_1.dart) + +fixed errors diff --git a/bin/dart_application_1.dart b/bin/dart_application_1.dart index 2404519..5d5658f 100644 --- a/bin/dart_application_1.dart +++ b/bin/dart_application_1.dart @@ -10,34 +10,53 @@ class View { Color? color; View(this.id, {this.color}); - - @override +@override String toString() { return '$id'; } + +} +class Text extends View{ + String? content; + + Text(int id, this.content, {Color? color}) : super(id, color: color); +/* if we want to print the content and id + * we can add this and remove the toString method in the View class + @override + String toString() { + return '$content and $id'; + } */ } - 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); - +var helloText = Text(id,'Hello'); + print('hello: $helloText'); + //this will output [hello: "number"] number will be different after every run because it's random number + task2(); + /* + this will call the task2() + + */ } void task2() { List numbers = List.generate(75, (index) => Random().nextInt(10000)); + List evenNumbers=[]; /* - Separate even numbers from the above `numbers` list. - List evenNumbers = ... + Looping through the `numbers` list. + If the number even it will be add to the evenNumbers list */ + for (final i in numbers) { + if (i.isEven) { + evenNumbers.add(i); + + }} print('evenNumbers: $evenNumbers'); + /* + And this will print the even numbers from the list numbers like this + 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] + */ } diff --git a/errors_in_dart_application_1.dart.png b/errors_in_dart_application_1.dart.png deleted file mode 100644 index bf239c7..0000000 Binary files a/errors_in_dart_application_1.dart.png and /dev/null differ diff --git a/fix errors_in_dart_application_1.dart.png b/fix errors_in_dart_application_1.dart.png new file mode 100644 index 0000000..fec97b4 Binary files /dev/null and b/fix errors_in_dart_application_1.dart.png differ