Class: Interfaz
- Inherits:
-
Object
- Object
- Interfaz
- Defined in:
- lib/exam1/examen.rb
Instance Attribute Summary collapse
-
#correctaP ⇒ Object
Returns the value of attribute correctaP.
-
#interfaz ⇒ Object
Returns the value of attribute interfaz.
Instance Method Summary collapse
- #calificacion ⇒ Object
- #correcta(ans_usuario, numero_preg) ⇒ Object
-
#initialize(examen) ⇒ Interfaz
constructor
A new instance of Interfaz.
- #invert ⇒ Object
- #respuesta_correcta ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(examen) ⇒ Interfaz
Returns a new instance of Interfaz.
106 107 108 109 110 111 |
# File 'lib/exam1/examen.rb', line 106 def initialize (examen) @interfaz = examen @correctaP = 0 end |
Instance Attribute Details
#correctaP ⇒ Object
Returns the value of attribute correctaP.
104 105 106 |
# File 'lib/exam1/examen.rb', line 104 def correctaP @correctaP end |
#interfaz ⇒ Object
Returns the value of attribute interfaz.
104 105 106 |
# File 'lib/exam1/examen.rb', line 104 def interfaz @interfaz end |
Instance Method Details
#calificacion ⇒ Object
161 162 163 164 165 166 167 168 169 170 |
# File 'lib/exam1/examen.rb', line 161 def calificacion if @correctaP >= 3 then puts "Calificación: Aprobado" true else puts "Calificación: Suspendido" false end end |
#correcta(ans_usuario, numero_preg) ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/exam1/examen.rb', line 119 def correcta(ans_usuario,numero_preg) if ans_usuario == @interfaz.rcorrecta[numero_preg] then puts "Pregunta #{numero_preg+1}: Respuesta correcta" @correctaP+=1 true else puts "Pregunta #{numero_preg+1}: Respuesta incorrecta" false end end |
#invert ⇒ Object
172 173 174 |
# File 'lib/exam1/examen.rb', line 172 def invert @interfaz.invert end |
#respuesta_correcta ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/exam1/examen.rb', line 134 def respuesta_correcta if @interfaz.respuesta_usuario != @interfaz.rcorrecta puts "Hay respuestas erroneas\n\n" for i in (0..4) if @interfaz.respuesta_usuario[i] != @interfaz.rcorrecta[i] puts "Pregunta #{i+1} incorrecta " elsif @interfaz.respuesta_usuario[i] == @interfaz.rcorrecta[i] puts "Pregunta #{i+1} correcta " end end elsif vresp_user == rcorrecta puts "Todas las respuestas son correctas\n" end end |
#to_s ⇒ Object
113 114 115 116 117 |
# File 'lib/exam1/examen.rb', line 113 def to_s @interfaz.to_s end |