So as part of my journey learning elixir, i decided to write a small guessing game in elixir.
Decided to do this to understand and experiment with elixir because the book seems long for me.
But i kept making simple mistakes and complex ones. I got my head around the simple ones when i go back to the book and do a little reading but this complex ones still keep hitting me strong in the head.
It has been two weeks since i decided to write a blog post concerning a working guexxir(Name of my elixir guesser game).
Ok so now i am actually writing the post but my game is still not working. So this is my code structure. Help me fix it.
defmodule GuesElixir do
def welcome_player do
IO.puts String.duplicate("*", 80)
IO.puts "Howdy! Let's GUEZZ A NAME"
IO.puts String.duplicate("*", 80)
end
def checkguess(""), do: "Massa Massa! i beg enter something"
def checkguess(n) do
guesses = ["abigail","ade", "nii", "equity","cecilia"]
if n in guesses do
IO.puts "HAAY!!! you guessed right. i really like #{n} o "
else
IO.puts "Sorry u know nothing about my life"
end
end
def enter_game_loop do
welcome_player()
urguess = IO.gets("What will be the name of my next best friend? ")
better_guess = String.lstrip(urguess, ?\n)
IO.puts "Ok so u guessed #{better_guess} , well lets see ......"
checkguess(urguess)
end
end
Nice try. I like how you used pattern matching for the
checkguess
methodenter_game_loop
method