Skip to content

Task3: table

daha edited this page Feb 22, 2012 · 2 revisions

The specification below is just a suggestion, improvements are welcomed. The code should preferably be unit tested with eunit.

-module(table). 
-behaviour(gen_server).

-type position() :: integer().
-type name() :: string().
-type enter_table_error_reason() :: {position_taken, position()} | {banned, name()}. 

% register with name ?MODULE
-spec stop() :: {ok, pid()}.
-spec stop() :: ok.

-spec enter_table(name(), position()) :: {ok, id()} | {error, enter_table_error_reason()}.
% should be possible to enter game with is ongoing, but should not make any
% "moves".
-spec leave_position(Position) :: ok | {error, leave_position_error_reason()}.
-spec leave_table() :: ok.
-spec get_vacant_positions() :: {ok, [position()]}.