This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
//Exercise 3 | |
//Question 1 | |
//Use the declared variables below to decide whether or not a person is eligible to rent movies | |
//A person is eligible when the age is more than 20 and the person can show his/her ID | |
//An example printout: Eligible to rent movies? false | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
var values = [1, 2, 3, 4, 5, 6, 7, 8, 9]; | |
var newVlues = <int>[]; | |
void Function(int) multiply5 = (value) => newVlues.add(value * 5); | |
listOperation(values, multiply5); | |
print(newVlues); | |
} | |
void listOperation(List<int> list, void Function(int) action) { | |
for (var item in list) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
var values = [1, 2, 3, 4, 5, 6, 7, 8, 9]; | |
var newVlues = <int>[]; | |
var multiply5 = (int value) => newVlues.add(value * 5); | |
listOperation(values, multiply5); | |
print(newVlues); | |
} | |
void listOperation(List<int> list, void Function(int) action) { | |
for (var item in list) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//typedef is a keyword | |
typedef Action = void Function(int); | |
void main() { | |
var values = [1, 2, 3, 4, 5, 6, 7, 8, 9]; | |
var newVlues = <int>[]; | |
void Function(int) multiply5 = (value) => newVlues.add(value * 5); | |
listOperation(values, multiply5); | |
print(newVlues); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
var doubleValues = [10.2, 2.2, 3.0, 4.5, 5.5, 6.0, 7.4, 80.0, 9.0]; | |
var stringValues = ['@','*', '&' ]; | |
var newDoubleVlues = <double>[]; | |
var newStringValue = <String>[]; | |
//listOperation(doubleValues, (double val) => newDoubleValues.add(val *3)); | |
listOperation(doubleValues,(double val) => newDoubleVlues.add(val * 5)); | |
listOperation(stringValues,(String val)=> newStringValue.add(val * 2)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
var doubleValues = [10.2, 2.2, 3.0, 4.5, 5.5, 6.0, 7.4, 80.0, 9.0]; | |
var stringValues = ['@','*', '&' ]; | |
var newDoubleVlues = <double>[]; | |
var newStringValue = <String>[]; | |
//listOperation(doubleValues, (double val) => newDoubleValues.add(val *3)); | |
listOperation(doubleValues,(double val) => newDoubleVlues.add(val * 5)); | |
listOperation(stringValues,(String val)=> newStringValue.add(val * 2)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
final list = [10, 20, 33]; | |
// for (var item in list) { | |
// print(item); | |
// } | |
//forEach | |
list.forEach((item) => print(item)); | |
list.forEach(print); | |
//Map Function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//use classes to define new type | |
//we are used to int, String, bool, List, Map, Set, Function | |
//classes - blueprint for objects | |
//object - container that holds some data (functionality in manipulate the data) | |
void main() { | |
var myHouse = House(nuOfWindows: 8, nuOfDoors: 4, typesOfWalls: 'Brick', typesOfRoof:'Tile'); | |
// myHouse.nrOfDoors = 10; | |
// | |
// print(myHouse.nrOfDoors); | |
myHouse.printHouses(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:math'; | |
void main() { | |
loveCalculator(); | |
} | |
void loveCalculator(){ | |
int loveScore = Random().nextInt(100) + 1; | |
print(loveScore); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
const Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override |
OlderNewer