Skip to content

Instantly share code, notes, and snippets.

@collinsnkem
Last active September 18, 2020 17:49
Show Gist options
  • Save collinsnkem/2a619343aff1809132017b35b72a96b5 to your computer and use it in GitHub Desktop.
Save collinsnkem/2a619343aff1809132017b35b72a96b5 to your computer and use it in GitHub Desktop.
Collins Dart Task Submit
import 'dart:collection';
void main() {
List myApp = [];
print(myApp.runtimeType);
print("\n");
//List Workout question 1 =======//
String kemswizz = 'My Name';
int age = 32;
bool isBig = true;
double shoeSize = 36.678;
String street = 'Agege, Lagos';
List myBio = List(5);
myBio[0] = kemswizz;
myBio[1] = age;
myBio[2] = isBig;
myBio[3] = shoeSize;
myBio[4] = street;
print(myBio);
print("\n");
//List Workout question 2 =======//
List<String> dynamicMob = List();
dynamicMob.add('Collins');
dynamicMob.add('Adedunni');
dynamicMob.add('Ibidapo');
dynamicMob.add('Tomiwa');
dynamicMob.add('Hassan');
dynamicMob.add('Roqeebat');
dynamicMob.add('Akintomiwa');
dynamicMob.add('Iya Eleba');
dynamicMob.add('Kilanko');
dynamicMob.add('Luke');
if (dynamicMob.length == 10) {
dynamicMob.removeRange(5, 10);
print(dynamicMob);
//Another way to print out the elements are==//
dynamicMob.forEach((value) => print(value));
//or
print("\n");
for (String values in dynamicMob) {
print(values);
}
} else {
print('I am a billionare');
}
print("\n");
//====Basic Workout Questions 1======//
LifeRace future = LifeRace();
List<LifeRace> moneyTalk = [
LifeRace(
name: "Chief Nkemdirim Collins", num: 16000000, isMillionaire: true),
LifeRace(name: "Hon. Femi Otedola", num: 980000, isMillionaire: false),
LifeRace(name: "Joseph Morenike", val: 0.0056)
];
var collins = moneyTalk[0];
var otedola = moneyTalk[1];
var dunni = moneyTalk[2];
future.num = 1;
if (collins.num > 1000000) {
print("${collins.name} is way Richer than ${otedola.name}");
} else if (otedola.num > 1000000) {
print("${otedola.name} is way Richer than ${collins.name}");
} else {
print('Life never balance');
}
//===== Basic Workout Questions 2 (String Interpolation)======//
print("\n");
if (collins.num < future.num) {
print("${collins.name} is way Richer than ${otedola.name}");
} else if (dunni.val > future.num) {
print("${dunni.name} needs Jesus in her life");
} else {
print('Chai, Life never balance oooo');
}
//======Map Workout Questions 1 ===========//
print("\n");
Map<String, int> users = Map();
users["Adedunni"] = 198;
users["Collins"] = 26;
users["Ibidapo"] = 18;
users["Tomiwa"] = 88;
users.forEach((key, value) =>
print("The student name is $key, and is $value years old"));
print('\n');
//=====Mixing the Users ID============//
SplayTreeMap someUsers = SplayTreeMap();
someUsers.addAll({"Adedunni": 99});
someUsers.addAll({"Collins": 34});
someUsers.addAll({"Ibidapo": 234});
someUsers.addAll({"Tomiwa": 111});
var mixTheID = someUsers.values.toList();
mixTheID.shuffle();
print(mixTheID);
someUsers.forEach((key, value) =>
print("The student name is $key, and is $value years old"));
}
class LifeRace {
final String name;
int num;
final bool isMillionaire;
final double val;
LifeRace({this.isMillionaire, this.name, this.num, this.val});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment