Inventory Management
Mix.install([
{:kino, github: "livebook-dev/kino", override: true},
{:kino_lab, "~> 0.1.0-dev", github: "jonatanklosko/kino_lab"},
{:vega_lite, "~> 0.1.4"},
{:kino_vega_lite, "~> 0.1.1"},
{:benchee, "~> 0.1"},
{:ecto, "~> 3.7"},
{:math, "~> 0.7.0"},
{:faker, "~> 0.17.0"},
{:utils, path: "#{__DIR__}/../utils"},
{:tested_cell, git: "https://github.com/BrooklinJazz/tested_cell"}
])
Navigation
Inventory Management
We’re going to build an in-memory inventory management application. We need to be able to start a process and return it’s PID.
pid = Warehouse.start()
We should be able to store an item with a quantity in our warehouse. If we store the same item in should increase the quantity.
Warehouse.store(pid, :apples, 5)
Warehouse.store(pid, :apples, 10)
We should be able to retrieve the current quantity of an item in our warehouse.
15 = Warehouse.quantity(pid, :apples)
You are free to solve the problem how you see fit. However, you might consider using a GenServer
, Agent
, or :ets
table.
Enter your solution in the Elixir cell below.
defmodule Warehouse do
def start do
end
def store(pid, item, quantity) do
end
def quantity(pid, item) do
end
end
Commit Your Progress
Run the following in your command line from the project folder to track and save your progress in a Git commit.
$ git add .
$ git commit -m "finish inventory management exercise"