<!DOCTYPE html>
<html> <head> <meta charset=“UTF-8”>
<title>examen.rb~ - RDoc Documentation</title>
<link href=“./fonts.css” rel=“stylesheet”> <link href=“./rdoc.css” rel=“stylesheet”>
<script type=“text/javascript”>
var rdoc_rel_prefix = "./";
</script>
<script src=“./js/jquery.js”></script> <script src=“./js/navigation.js”></script> <script src=“./js/search_index.js”></script> <script src=“./js/search.js”></script> <script src=“./js/searcher.js”></script> <script src=“./js/darkfish.js”></script>
<body id=“top” role=“document” class=“file”> <nav role=“navigation”>
<div id="project-navigation"> <div id="home-section" role="region" title="Quick navigation" class="nav-section"> <h2> <a href="./index.html" rel="home">Home</a> </h2> <div id="table-of-contents-navigation"> <a href="./table_of_contents.html#pages">Pages</a> <a href="./table_of_contents.html#classes">Classes</a> <a href="./table_of_contents.html#methods">Methods</a> </div>
</div>
<div id="search-section" role="search" class="project-section initially-hidden"> <form action="#" method="get" accept-charset="utf-8"> <div id="search-field-wrapper"> <input id="search-field" role="combobox" aria-label="Search" aria-autocomplete="list" aria-controls="search-results" type="text" name="search" placeholder="Search" spellcheck="false" title="Type to search, Up and Down to navigate, Enter to load"> </div> <ul id="search-results" aria-label="Search Results" aria-busy="false" aria-expanded="false" aria-atomic="false" class="initially-hidden"></ul> </form>
</div>
</div>
<div class=“nav-section”>
<h3>Table of Contents</h3> <ul class="link-list" role="directory"> <li><a href="#label-begin">begin</a> <li><a href="#label-end">end</a> </ul>
</div>
<div id="project-metadata"> <div id="fileindex-section" class="nav-section"> <h3>Pages</h3> <ul class="link-list"> <li><a href="./SeleccionSimple_rb~.html">SeleccionSimple.rb~</a> <li><a href="./examen_rb~.html">examen.rb~</a> <li><a href="./linkedlist_rb~.html">linkedlist.rb~</a> </ul>
</div>
</div>
</nav>
<main role=“main” aria-label=“Page examen.rb~”>
<p>require 'exam1/SeleccionSimple' require 'exam1/linkedlist'</p>
<p>class <a href=“Examen.html”>Examen</a></p>
<p>attr_accessor :exam, :respuesta_usuario, :rcorrecta, :correctaP</p>
<pre class=“ruby”><span class=“ruby-keyword”>def</span> <span class=“ruby-identifier”>initialize</span> (<span class=“ruby-identifier”>lista_preguntas</span>)
<span class="ruby-ivar">@exam</span> = <span class="ruby-identifier">lista_preguntas</span> <span class="ruby-ivar">@respuesta_usuario</span>=[<span class="ruby-keyword">nil</span>,<span class="ruby-keyword">nil</span>,<span class="ruby-keyword">nil</span>,<span class="ruby-keyword">nil</span>,<span class="ruby-keyword">nil</span>] <span class="ruby-ivar">@rcorrecta</span> = [<span class="ruby-string">'b'</span>,<span class="ruby-string">'a'</span>,<span class="ruby-string">'c'</span>,<span class="ruby-string">'a'</span>,<span class="ruby-string">'a'</span>] <span class="ruby-ivar">@correctaP</span>=<span class="ruby-value">0</span>
<span class=“ruby-keyword”>end</span>
<span class=“ruby-keyword”>def</span> <span class=“ruby-identifier”>respuesta_user</span>
<span class=“ruby-identifier”>puts</span> <span class=“ruby-string”>"Introduce las opciones de respuesta: "</span> </pre>
<h1 id=“label-begin”>begin<span><a href=“#label-begin”>¶</a> <a href=“#documentation”>↑</a></span></h1>
<pre>puts "1): " + r1=gets.chomp puts "2): " + r2=gets.chomp puts "3): " + r3=gets.chomp puts "4): " + r4=gets.chomp puts "5): " + r5=gets.chomp</pre>
<h1 id=“label-end”>end<span><a href=“#label-end”>¶</a> <a href=“#documentation”>↑</a></span></h1>
<p># @respuesta_usuario = [r1,r2,r3,r4,r5]</p>
<pre class=“ruby”><span class=“ruby-ivar”>@respuesta_usuario</span> = [<span class=“ruby-identifier”>gets</span>.<span class=“ruby-identifier”>chomp</span>,<span class=“ruby-identifier”>gets</span>.<span class=“ruby-identifier”>chomp</span>,<span class=“ruby-identifier”>gets</span>.<span class=“ruby-identifier”>chomp</span>,<span class=“ruby-identifier”>gets</span>.<span class=“ruby-identifier”>chomp</span>,<span class=“ruby-identifier”>gets</span>.<span class=“ruby-identifier”>chomp</span>]
<span class=“ruby-keyword”>end</span>
<span class=“ruby-keyword”>def</span> <span class=“ruby-identifier”>vresp_user</span>
<span class="ruby-keyword">return</span> <span class="ruby-ivar">@respuesta_usuario</span>
<span class=“ruby-keyword”>end</span>
<span class=“ruby-keyword”>def</span> <span class=“ruby-identifier”>correcta</span>(<span class=“ruby-identifier”>ans_usuario</span>,<span class=“ruby-identifier”>numero_preg</span>)
<span class="ruby-keyword">if</span> <span class="ruby-identifier">ans_usuario</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@rcorrecta</span>[<span class="ruby-identifier">numero_preg</span>] <span class="ruby-keyword">then</span> <span class="ruby-identifier">puts</span> <span class="ruby-node">"Pregunta #{numero_preg+1}: Respuesta correcta"</span> <span class="ruby-ivar">@correctaP</span><span class="ruby-operator">+=</span><span class="ruby-value">1</span> <span class="ruby-keyword">true</span> <span class="ruby-keyword">else</span> <span class="ruby-identifier">puts</span> <span class="ruby-node">"Pregunta #{numero_preg+1}: Respuesta incorrecta"</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">end</span>
<span class=“ruby-keyword”>end</span>
<span class=“ruby-keyword”>def</span> <span class=“ruby-identifier”>calificacion</span>
<span class="ruby-keyword">if</span> <span class="ruby-ivar">@correctaP</span> <span class="ruby-operator">>=</span> <span class="ruby-value">3</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">puts</span> <span class="ruby-string">"Calificación: Aprobado"</span> <span class="ruby-keyword">true</span> <span class="ruby-keyword">else</span> <span class="ruby-identifier">puts</span> <span class="ruby-string">"Calificación: Suspendido"</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">end</span>
<span class=“ruby-keyword”>end</span>
<span class=“ruby-keyword”>def</span> <span class=“ruby-identifier”>to_s</span>
<span class="ruby-identifier">actual</span> = <span class="ruby-ivar">@exam</span>.<span class="ruby-identifier">tail</span> <span class="ruby-identifier">i</span>=<span class="ruby-value">1</span> <span class="ruby-keyword">while</span> <span class="ruby-identifier">actual</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">i</span> <span class="ruby-operator"><</span> <span class="ruby-value">6</span> <span class="ruby-identifier">puts</span> <span class="ruby-node">"#{i} #{actual.value}\n"</span> <span class="ruby-identifier">actual</span> = <span class="ruby-identifier">actual</span>.<span class="ruby-identifier">siguiente</span> <span class="ruby-identifier">i</span><span class="ruby-operator">+=</span><span class="ruby-value">1</span> <span class="ruby-keyword">end</span>
<span class=“ruby-keyword”>end</span>
<span class=“ruby-keyword”>def</span> <span class=“ruby-identifier”>invert</span>
<span class="ruby-ivar">@exam</span>.<span class="ruby-identifier">reverse_each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">puts</span> <span class="ruby-node">"#{x}\n"</span> } <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
<span class=“ruby-keyword”>end</span> </pre>
<p>end</p>
<p>class <a href=“Interfaz.html”>Interfaz</a></p>
<p>attr_accessor :interfaz, :correctaP</p>
<p>def initialize (examen)</p>
<pre>@interfaz = examen @correctaP = 0</pre>
<p>end</p>
<p>def to_s</p>
<pre>@interfaz.to_s</pre>
<p>end</p>
<p>def correcta(ans_usuario,numero_preg)</p>
<pre>if ans_usuario == @interfaz.rcorrecta then
puts "Pregunta #{numero_preg+1}: Respuesta correcta" @correctaP+=1 true
else
puts "Pregunta #{numero_preg+1}: Respuesta incorrecta" false
end</pre>
<p>end</p>
<p>def respuesta_correcta</p>
<pre>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</pre>
<p>end</p>
<p>def calificacion</p>
<pre>if @correctaP >= 3 then
puts "Calificación: Aprobado" true
else
puts "Calificación: Suspendido" false
end</pre>
<p>end</p>
<p>end</p> </main>
<footer id=“validator-badges” role=“contentinfo”>
<p><a href="http://validator.w3.org/check/referer">Validate</a> <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.0. <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>