| import System.Exit
|
|
|
| gameOne :: IO ()
|
| gameOne = do
|
| putStrLn "Please enter your name"
|
| name <- getLine
|
| putStrLn $ "hellooo " ++ name ++ "! How are you todays?"
|
| answer <- getLine
|
| putStrLn $ questionResponse answer
|
| putStrLn "wanna play a game?"
|
| answerOne <- getLine
|
| if endGameOne answerOne == False
|
| then exitSuccess
|
| else
|
| putStrLn $ questionOne answerOne
|
| putStrLn "choose one of the 3 numbers: 1 , 2 or 3"
|
| num <- getLine
|
| putStrLn $ "you have chosen " ++ foodChoice num ++ ". nice!"
|
|
|
|
|
| questionOne :: String -> String
|
| questionOne x =
|
| case x of
|
| "yes" -> "alright. lets play!"
|
| "no" -> "understandable. Have a good day!"
|
| otherwise -> "DECIDE. NOW!"
|
|
|
| endGame :: String -> IO ()
|
| endGame strn = do
|
| if strn == "no"
|
| then putStrLn $ "have a good day!"
|
| else putStrLn $ questionOne ""
|
|
|
| foodChoice :: String -> String
|
| foodChoice x =
|
| case x of
|
| "1" -> "Burrito"
|
| "2" -> "enchiladas"
|
| "3" -> "tacos"
|
| otherwise -> "nothing"
|
|
|
| questionResponse :: String -> String
|
| questionResponse x =
|
| case x of
|
| "good" -> "Alright. glad you're doing well!"
|
| "bad" -> "aww. I hope you're doing better!"
|
| "ok" -> "thats good. Not too bad."
|
| "okay" -> "thats good. Not too bad."
|
| "alright" -> "Alright, huh? thats good!"
|
| otherwise -> "ANSWER!"
|
|
|
| endGameOne :: String -> Bool
|
| endGameOne "yes" = True
|
| endgameOne "no" = False
|
|
|
| main :: IO ()
|
| main = do
|
| gameOne
|