<!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 &#39;exam1/SeleccionSimple&#39; require &#39;exam1/linkedlist&#39;</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">&#39;b&#39;</span>,<span class="ruby-string">&#39;a&#39;</span>,<span class="ruby-string">&#39;c&#39;</span>,<span class="ruby-string">&#39;a&#39;</span>,<span class="ruby-string">&#39;a&#39;</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”>&quot;Introduce las opciones de respuesta: &quot;</span> </pre>

<h1 id=“label-begin”>begin<span><a href=“#label-begin”>&para;</a> <a href=“#documentation”>&uarr;</a></span></h1>

<pre>puts &quot;1): &quot; + r1=gets.chomp puts &quot;2): &quot; + r2=gets.chomp puts &quot;3): &quot; + r3=gets.chomp puts &quot;4): &quot; + r4=gets.chomp puts &quot;5): &quot; + r5=gets.chomp</pre>

<h1 id=“label-end”>end<span><a href=“#label-end”>&para;</a> <a href=“#documentation”>&uarr;</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">&quot;Pregunta #{numero_preg+1}: Respuesta correcta&quot;</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">&quot;Pregunta #{numero_preg+1}: Respuesta incorrecta&quot;</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">&gt;=</span> <span class="ruby-value">3</span> <span class="ruby-keyword">then</span>
        <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;Calificación: Aprobado&quot;</span>
        <span class="ruby-keyword">true</span>
<span class="ruby-keyword">else</span>
        <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;Calificación: Suspendido&quot;</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">&amp;&amp;</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">6</span>

        <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{i} #{actual.value}\n&quot;</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">&quot;#{x}\n&quot;</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 &quot;Pregunta #{numero_preg+1}: Respuesta correcta&quot;
@correctaP+=1
true

else

puts &quot;Pregunta #{numero_preg+1}: Respuesta incorrecta&quot;
false

end</pre>

<p>end</p>

<p>def respuesta_correcta</p>

<pre>if @interfaz.respuesta_usuario != @interfaz.rcorrecta

puts &quot;Hay respuestas erroneas\n\n&quot;

for i in (0..4)

        if @interfaz.respuesta_usuario[i] != @interfaz.rcorrecta[i] 
                puts &quot;Pregunta #{i+1} incorrecta &quot;

        elsif @interfaz.respuesta_usuario[i] == @interfaz.rcorrecta[i] 
                puts &quot;Pregunta #{i+1} correcta &quot;
        end

end

elsif vresp_user == rcorrecta

puts &quot;Todas las respuestas son correctas\n&quot;

end</pre>

<p>end</p>

<p>def calificacion</p>

<pre>if @correctaP &gt;= 3 then

puts &quot;Calificación: Aprobado&quot;
true

else

puts &quot;Calificación: Suspendido&quot;
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>