Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local QUIZZ = {
- print = function(self, n) print("Question ".. n.. ") ".. self[n].question .. "\n".. self[n].choices) end,
- {question = "When have we walked on the Moon for the first time ?", choices = "A) 1964,\nB) 1969,\nC) 1974", answer = "B"},
- {question = "When Michael Jackson died ?", choices = "A) 2009\nB) 2010\nC) 2011", answer = "A"}
- }
- local PLAYER = {
- printScore = function(self) local s = 0; for i = 1, #QUIZZ do s = s + (self[i] == QUIZZ[i].answer and 1 or 0) end print("Your score is : ".. s.. "/".. #QUIZZ) end
- }
- for i = 1, #QUIZZ do
- QUIZZ:print(i)
- PLAYER[i] = io.read():upper()
- print((PLAYER[i] == QUIZZ[i].answer) and "Right !" or "Wrong !")
- os.execute("pause")
- os.execute("cls")
- end
- PLAYER:printScore()
- os.execute("pause")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement