class Exam

Attributes

answer[R]
correct[R]
fail[R]
listp[R]
nota[R]

Public Class Methods

new(p) click to toggle source
# File lib/my_gem/exam.rb, line 8
def initialize(p)
        @listp=List.new
        for i in(0...p.size)
                @listp.pushhead(p[i])
        end
        @correct=0
        @fail=0
        @nota=0
        @answer=nil
end

Public Instance Methods

calcnote() click to toggle source
# File lib/my_gem/exam.rb, line 39
def calcnote
        @nota=@correct*10/(@correct+@fail)
end
checkquestion(ans) click to toggle source

Imprime las preguntas y pide la respuesta del usuario

# File lib/my_gem/exam.rb, line 19
def checkquestion(ans)
        #imprime pregunta y pide respuesta por pantalla.
        #@listp.tail.value.show()
        @answer=ans
        if @answer==@listp.tail.value.t
                @correct+=1
                #print "Usted eligio: ", @answer, "\n"
                #puts "Respuesta correcta", "\n"
        else
                @fail+=1
                #print "Usted eligio: ", @answer, "\n"
                #puts "Respuesta incorrecta", "\n"
        end
        @listp.poptail
end
reverse() click to toggle source
# File lib/my_gem/exam.rb, line 34
def reverse
        @aux=List.new
        @listp.reverse_each{|v| @aux.pushhead(v)}
        @listp=@aux
end