diff --git a/exercises/high-scores/.meta/HINTS.md b/exercises/high-scores/.meta/HINTS.md new file mode 100644 index 00000000000..d1d5af1196e --- /dev/null +++ b/exercises/high-scores/.meta/HINTS.md @@ -0,0 +1,5 @@ +In this exercise you're going to create a **class** and use lists to organize scores. _Don't worry, it's not as complicated as you think!_ + +- [**A First Look at Classes**](https://docs.python.org/3/tutorial/classes.html#a-first-look-at-classes) from the Python 3 documentation. +- [**How to Define a Class in Python**](https://realpython.com/python3-object-oriented-programming/#how-to-define-a-class-in-python) from the Real Python website. +- [**Data Structures in Python**](https://docs.python.org/3/tutorial/datastructures.html) from the Python 3 documentation. diff --git a/exercises/high-scores/README.md b/exercises/high-scores/README.md index 802ad5ac1ee..6b08db6eb92 100644 --- a/exercises/high-scores/README.md +++ b/exercises/high-scores/README.md @@ -4,19 +4,59 @@ 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 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. -## Submitting Exercises +In this exercise you're going to create a **class** and use lists to organize scores. _Don't worry, it's not as complicated as you think!_ + +- [**A First Look at Classes**](https://docs.python.org/3/tutorial/classes.html#a-first-look-at-classes) from the Python 3 documentation. +- [**How to Define a Class in Python**](https://realpython.com/python3-object-oriented-programming/#how-to-define-a-class-in-python) from the Real Python website. +- [**Data Structures in Python**](https://docs.python.org/3/tutorial/datastructures.html) from the Python 3 documentation. + + + +## Exception messages + +Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to +indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not +every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include +a message. + +To raise a message with an exception, just write it as an argument to the exception type. For example, instead of +`raise Exception`, you should write: + +```python +raise Exception("Meaningful message indicating the source of the error") +``` + +## Running the tests -Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/` directory. +To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)): -For example, if you're submitting `bob.py` for the Bob exercise, the submit command would be something like `exercism submit /python/bob/bob.py`. +- Python 2.7: `py.test high_scores_test.py` +- Python 3.4+: `pytest high_scores_test.py` +Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version): +`python -m pytest high_scores_test.py` + +### Common `pytest` options + +- `-v` : enable verbose output +- `-x` : stop running tests on first failure +- `--ff` : run failures from previous test before running other test cases + +For other options, see `python -m pytest -h` + +## Submitting Exercises + +Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/high-scores` directory. + +You can find your Exercism workspace by running `exercism debug` and looking for the line that starts with `Workspace`. For more detailed information about running tests, code style and linting, -please see the [help page](http://exercism.io/languages/python). +please see [Running the Tests](http://exercism.io/tracks/python/tests). ## Source Tribute to the eighties' arcade game Frogger ## Submitting Incomplete Solutions + It's possible to submit an incomplete solution so you can see how others have completed the exercise.