Skip to content

Commit

Permalink
Implement high-scores in dart
Browse files Browse the repository at this point in the history
  • Loading branch information
Sgoettschkes committed Nov 18, 2023
1 parent 905197c commit 7a68273
Show file tree
Hide file tree
Showing 7 changed files with 547 additions and 0 deletions.
38 changes: 38 additions & 0 deletions dart/high-scores/HELP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Help

## Running the tests

To run the tests:

```sh
$ dart test
```

## Submitting your solution

You can submit your solution using the `exercism submit lib/high_scores.dart` command.
This command will upload your solution to the Exercism website and print the solution page's URL.

It's possible to submit an incomplete solution which allows you to:

- See how others have completed the exercise
- Request help from a mentor

## Need to get help?

If you'd like help solving the exercise, check the following pages:

- The [Dart track's documentation](https://exercism.org/docs/tracks/dart)
- The [Dart track's programming category on the forum](https://forum.exercism.org/c/programming/dart)
- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5)
- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)

Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.

To get help if you're having trouble, you can use one of the following resources:

- [Dart API Documentation](https://api.dart.dev/)
- [Dart Gitter Chat](https://gitter.im/dart-lang/home)
- [Community Information](https://www.dart.dev/community)
- [/r/dartlang](https://www.reddit.com/r/dartlang) is the Dart subreddit.
- [StackOverflow](https://stackoverflow.com/questions/tagged/dart) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions.
25 changes: 25 additions & 0 deletions dart/high-scores/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# High Scores

Welcome to High Scores on Exercism's Dart Track.
If you need help running the tests or submitting your code, check out `HELP.md`.

## Instructions

Manage a game player's High Score list.

Your task is to build a high-score component of the classic Frogger game, one of the highest selling and most addictive games of all time, and a classic of the arcade era.
Your task is to write methods that return the highest score from the list, the last added score and the three highest scores.

## Source

### Created by

- @Stargator

### Contributed to by

- @kytrinyx

### Based on

Tribute to the eighties' arcade game Frogger
18 changes: 18 additions & 0 deletions dart/high-scores/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
errors:
unused_element: error
unused_import: error
unused_local_variable: error
dead_code: error

linter:
rules:
# Error Rules
- avoid_relative_lib_imports
- avoid_types_as_parameter_names
- literal_only_boolean_expressions
- no_adjacent_strings_in_list
- valid_regexps
21 changes: 21 additions & 0 deletions dart/high-scores/lib/high_scores.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class HighScores {
List<int> scores = [];

HighScores(this.scores);

int latest() {
return this.scores.last;
}

int personalBest() {
var localScores = scores.toList()..sort();

return localScores.last;
}

List<int> personalTopThree() {
var localScores = scores.toList()..sort();

return localScores.reversed.toList().take(3).toList();
}
}
Loading

0 comments on commit 7a68273

Please sign in to comment.