Class: Quiz

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/depscale.rb

Instance Method Summary collapse

Constructor Details

#initializeQuiz

Returns a new instance of Quiz.



9
10
11
# File 'lib/depscale.rb', line 9

def initialize
  @questions = []
end

Instance Method Details

#add_question(question) ⇒ Object



13
14
15
# File 'lib/depscale.rb', line 13

def add_question(question)
  @questions << question
end

#last_questionObject



17
18
19
# File 'lib/depscale.rb', line 17

def last_question
  @questions.last
end

#run_quizObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/depscale.rb', line 21

def run_quiz
  count=0
  @questions.each { |q| count += 1 if q.ask }
  puts "You got a score of #{count} \n"
  case count 
when 1..5
puts "You are in good mood , there is no evidence of depression"
when 6..10
puts "Your answers are suggestive of depression \n There is a need for more assessment"
when 11..20
puts "Your answers are indicative of depression, you need to seek psychiatric consultation"
  end
end