Class: Examen
- Inherits:
-
Object
- Object
- Examen
- Defined in:
- lib/exam/examen.rb
Instance Attribute Summary (collapse)
-
- (Object) acierto
Returns the value of attribute acierto.
-
- (Object) fallo
Returns the value of attribute fallo.
-
- (Object) list
Returns the value of attribute list.
-
- (Object) node_i
Returns the value of attribute node_i.
Instance Method Summary (collapse)
-
- (Examen) initialize(list)
constructor
A new instance of Examen.
- - (Object) next_question
- - (Object) response_question(value)
- - (Object) reverse_question
- - (Object) show_stats
Constructor Details
- (Examen) initialize(list)
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
- (Object) acierto
Returns the value of attribute acierto
11 12 13 |
# File 'lib/exam/examen.rb', line 11 def acierto @acierto end |
- (Object) fallo
Returns the value of attribute fallo
11 12 13 |
# File 'lib/exam/examen.rb', line 11 def fallo @fallo end |
- (Object) list
Returns the value of attribute list
11 12 13 |
# File 'lib/exam/examen.rb', line 11 def list @list end |
- (Object) node_i
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
- (Object) next_question
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 |
- (Object) response_question(value)
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 |
- (Object) reverse_question
32 33 34 |
# File 'lib/exam/examen.rb', line 32 def reverse_question @list.reverse end |
- (Object) show_stats
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 |