Class: Examen
- Inherits:
-
Object
- Object
- Examen
- Defined in:
- lib/exam/examen.rb
Instance Attribute Summary collapse
-
#acierto ⇒ Object
Returns the value of attribute acierto.
-
#fallo ⇒ Object
Returns the value of attribute fallo.
-
#list ⇒ Object
Returns the value of attribute list.
-
#node_i ⇒ Object
Returns the value of attribute node_i.
Instance Method Summary collapse
-
#initialize(list) ⇒ Examen
constructor
A new instance of Examen.
- #next_question ⇒ Object
- #response_question(value) ⇒ Object
- #reverse_question ⇒ Object
- #show_stats ⇒ Object
Constructor Details
#initialize(list) ⇒ Examen
Returns a new instance of Examen.
12 13 14 15 16 |
# File 'lib/exam/examen.rb', line 12 def initialize(list) @acierto = 0 @fallo = 0 @list = list end |
Instance Attribute Details
#acierto ⇒ Object
Returns the value of attribute acierto.
11 12 13 |
# File 'lib/exam/examen.rb', line 11 def acierto @acierto end |
#fallo ⇒ Object
Returns the value of attribute fallo.
11 12 13 |
# File 'lib/exam/examen.rb', line 11 def fallo @fallo end |
#list ⇒ Object
Returns the value of attribute list.
11 12 13 |
# File 'lib/exam/examen.rb', line 11 def list @list end |
#node_i ⇒ Object
Returns the value of attribute node_i.
11 12 13 |
# File 'lib/exam/examen.rb', line 11 def node_i @node_i end |
Instance Method Details
#next_question ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/exam/examen.rb', line 18 def next_question() if @node_i != nil then if @node_i.next != nil then @node_i = @node_i.next else return nil end else @node_i = @list.head end puts @node_i.value.to_s return @node_i.value.to_s end |
#response_question(value) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/exam/examen.rb', line 35 def response_question(value) print "Respuesta: " if value == @node_i.value.right then puts "\n" puts "La pregunta es correcta" puts "\n" @acierto += 1 else puts "\n" puts "La pregunta es incorrecta" puts "\n" @fallo += 1 end end |
#reverse_question ⇒ Object
32 33 34 |
# File 'lib/exam/examen.rb', line 32 def reverse_question @list.reverse end |
#show_stats ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/exam/examen.rb', line 49 def show_stats puts "\n" puts "|---------------------------|" puts "|--- Estadisticas ---|" puts "|---------------------------|" puts "|- Aciertos: #{@acierto} | Fallos: #{@fallo} -|" puts "|---------------------------|" puts "\n" end |