diff --git a/bin/dart_application_1.dart b/bin/dart_application_1.dart index 2404519..e6ef681 100644 --- a/bin/dart_application_1.dart +++ b/bin/dart_application_1.dart @@ -17,27 +17,31 @@ 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'); + //console output {hello: 2353} this number will be change after every eun because it's random number + } 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'); + //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] }