Tracks
/
Perl
Perl
/
Exercises
/
High Score Board
High Score Board

High Score Board

Learning Exercise

Instructions

You're going to write some code to manage a scoreboard for a game. The scoreboard will be a hash called %HighScoreBoard::Scores. The keys of the hash will be the names of the players, and the values will be their scores.

1. Set a player's score in the %Scores hash

Modify the HighScoreBoard::set_player_scores subroutine, which takes player names and scores as arguments, to set the players' scores in the %HighScoreBoard::Scores hash.

2. Get a player's score from the %Scores hash

Modify the HighScoreBoard::get_player_score subroutine, which takes a player name as an argument, to return the player's score from the %HighScoreBoard::Scores hash.

3. Increase a player's score in the %Scores hash

Modify the HighScoreBoard::increase_player_scores subroutine, which takes players names and scores as arguments, to increase the players' scores in the %HighScoreBoard::Scores hash by the given score.

4. Sort the players in the %Scores hash by their name

Modify the HighScoreBoard::sort_players_by_name subroutine to return the players names in the %HighScoreBoard::Scores hash sorted by their name.

5. Sort the players in the %Scores hash by their score

Modify the HighScoreBoard::sort_players_by_score subroutine to return the players names in the %HighScoreBoard::Scores hash sorted by their score.

6. Delete a player from the %Scores hash

Modify the HighScoreBoard::delete_player subroutine, which takes a player name as an argument, to delete the player from the %HighScoreBoard::Scores hash.

Edit via GitHub The link opens in a new window or tab
Perl Exercism

Ready to start High Score Board?

Sign up to Exercism to learn and master Perl with 5 concepts, 65 exercises, and real human mentoring, all for free.