Wrap text
|
|
-module (chingoon).
-export ([chingoon/1]).
-export ([chin_wrapper/1]).
line(Text) -> io:format(Text, []).
top() ->
line(" __________~n"),
line("(--[ .]-[ .]~n"),
line("( O )~n").
chin_wrapper(Parent) ->
chin(1),
Parent!{chin}.
chin_spawner(0) ->
0;
chin_spawner(Count) ->
spawn(chingoon, chin_wrapper, [self()]),
chin_spawner(Count - 1).
chin(0) -> 0;
chin(Count) ->
line("( )~n"),
chin(Count - 1).
bottom() ->
line("(__________)~n").
loop(0) ->
bottom();
loop(Num) ->
receive
{chin} ->
loop(Num - 1)
end.
chingoon(Num) when is_integer(Num), Num >= 0 ->
top(),
chin_spawner(Num),
loop(Num).
|