Class: Interface
Instance Attribute Summary
Attributes inherited from Examen
Instance Method Summary collapse
Methods inherited from Examen
Constructor Details
This class inherits a constructor from Examen
Instance Method Details
#comenzar ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/simpleselect/interface.rb', line 4 def comenzar @pos=0 @puntuacion=0 for cuestion in @preguntas.headToTail do puts cuestion print "\e[96m Su respuesta: " loop do @eleccion = gets.chomp.downcase[0] if (@eleccion == nil)then puts "Por favor introduzca una opcion valida" else break end end puts "\e[39m" if ( compara_resp(@pos,@eleccion) == true ) then puts "\e[92m |-> Respuesta correcta! <-|\e[39m\n " @puntuacion += 1 else puts "\e[91m |-> Respuesta incorrecta! <-|\e[39m\n " end loop do puts "\e[90mpulse enter para continuar (o i para mas informacion)\e[39m" cuestion=gets.chomp.downcase[0] if (cuestion == "i") then puts "Actual:#{@pos}\nTotal:#{@n}\nAcertadas:#{@puntuacion}\nFallidas:#{@pos+1-@puntuacion}" else break end end @pos += 1 end print "ha obtenido usted una puntuacion de " if (@puntuacion < (@pos/2) ) then print "\e[91m #{@puntuacion}" else print "\e[92m #{@puntuacion}" end print"\e[39m Sobre "+@pos.to_s+"\n" end |