Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Advanced Score Tracker

advanced_score_tracker.livemd

Advanced Score Tracker

Mix.install([
  {:jason, "~> 1.4"},
  {:kino, "~> 0.9", override: true},
  {:youtube, github: "brooklinjazz/youtube"},
  {:hidden_cell, github: "brooklinjazz/hidden_cell"}
])

Navigation

Home Report An Issue ETS Inventory ManagementMetaprogramming

Mastery

Mastery assignments are bonus projects designed to incorporate curriculum concepts at an advanced level. You have complete freedom with how you complete mastery assignments, and may change requirements as you see fit. Each mastery assignment serves as an independent project you may choose to include on your portfolio of projects.

Advanced Score Tracker

Create a new supervised mix project AdvancedScoreTracker.

$ mix new advanced_score_tracker --sup

The AdvancedScoreTracker will use an Agent to create a general purpose score tracker that tracks player score history across multiple different games. The AdvancedScoreTracker Agent should start as part of the application’s supervision tree.

Hint

Consider how you want to store your state, and how to update it. For example, you might consider a map.

state = %{
  player1: %{
    ping_pong: [0, 20]
  },
  player2: %{
    ping_pong: [0, 20]
    rock_paper_scissors: [3, 2]
  }
}

Test Cases

Create a full suite of test cases for all of the features described below.

Score

The AdvancedScoreTracker should be able to add a certain number of points given a player name and a game name. A game should start with 0 points by default.

AdvancedScoreTracker.add(:player1, :ping_pong, 10)
AdvancedScoreTracker.add(:player1, :ping_pong, 10)

It should also be able to retrieve the total number of points for the current game when provided the name of the game and the player.

20 = AdvancedScoreTracker.get(:player1, :ping_pong)

New Game

When a game is finished, AdvancedScoreTracker should be able to start a new point total with a default score of 0. The previous game total should be saved, see the History section below.

AdvancedScoreTracker.new(:player1, :ping_pong)
0 = AdvancedScoreTracker.get(:player1, :ping_pong)

History

Retrieve a history of scores for a player and a game as a list of point totals. The most recent game should be at the start of the list.

Each value should be the total number of points accumulated before calling AdvancedScoreTracker.new/2 to start a new game.

[0, 20] = AdvancedScoreTracker.history(:player1, :ping_pong)

High Score

Find a player’s highest score from their history.

20 = AdvancedScoreTracker.high_score(:player1, :ping_pong)

Find the highest score out of all players for a game.

20 = AdvancedScoreTracker.high_score(:ping_pong)

Create A GitHub Repository

Connect your AdvancedScoreTracker project to a GitHub repository and create a README to describe the purpose of the project and what you learned building it.

Commit Your Progress

DockYard Academy now recommends you use the latest Release rather than forking or cloning our repository.

Run git status to ensure there are no undesirable changes. Then run the following in your command line from the curriculum folder to commit your progress.

$ git add .
$ git commit -m "finish Advanced Score Tracker exercise"
$ git push

We’re proud to offer our open-source curriculum free of charge for anyone to learn from at their own pace.

We also offer a paid course where you can learn from an instructor alongside a cohort of your peers. We will accept applications for the June-August 2023 cohort soon.

Navigation

Home Report An Issue ETS Inventory ManagementMetaprogramming