Learning Dart

This commit is contained in:
2023-04-06 11:35:43 -05:00
parent fab045379a
commit b16a5813cc
92 changed files with 6437 additions and 21 deletions

View File

@@ -0,0 +1,22 @@
class HighScores {
List<int> scores = <int>[];
HighScores(List<int> s) {
scores = s;
}
int latest() => scores.last;
int personalBest() => _sorted().first;
List<int> personalTopThree() {
List<int> wrk = _sorted();
if(wrk.length >= 3) {
return wrk.sublist(0, 3);
}
return wrk;
}
List<int> _sorted() {
List<int> wrk = List.of(scores);
wrk.sort((e1, e2) => e2.compareTo(e1));
return wrk;
}
}