Skip to content

Commit

Permalink
Merge branch 'des'
Browse files Browse the repository at this point in the history
porque debemos hacer merge
  • Loading branch information
quinoescobar committed Nov 27, 2014
2 parents a4a9543 + 4fe7f42 commit 1a25fe0
Show file tree
Hide file tree
Showing 15 changed files with 542 additions and 102 deletions.
1 change: 1 addition & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
service_name: travis-ci
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: ruby

rvm:

- 1.9.3
- 1.9.2
- 2.1.1
- jruby-18mode # JRuby in 1.8 mode

- jruby-19mode # JRuby in 1.9 mode

- rbx-18mode

- rbx-19mode

- 1.8.7

4 changes: 1 addition & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ source 'https://rubygems.org'

# Specify your gem's dependencies in examen.gemspec
gemspec
gem 'guard'
gem 'guard-rspec'
gem 'guard-bundler'
gem 'coveralls', require: false
22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
Practica 6 LPP
[![Build Status](https://travis-ci.org/alu0100505092/prct08.svg?branch=des)](https://travis-ci.org/alu0100505092/prct08)
[![Coverage Status](https://img.shields.io/coveralls/alu0100505092/prct08.svg)](https://coveralls.io/r/alu0100505092/prct08)
[![Coverage Status](https://coveralls.io/repos/alu0100505092/prct08/badge.png)](https://coveralls.io/r/alu0100505092/prct08)
https://travis-ci.org/alu0100505092/prct08.svg?branch=des
https://travis-ci.org/alu0100505092/prct08.svg?branch=master

Practica 9 LPP

Integrantes LPP_T_13
Angelica Ravelo
Joaquin Escobar


Practica sobre Listas Enlazadas en RUBY( Linked List)
Practica sobre Clase Examen, y creacion clase Interfaz, en la clase Interfaz se comprueban las respuestas ingresadas por el usuario
, con sus expectativas.


Expectativas

Examen
Nodo
-Debe existir un Nodo de la lista con sus datos y su siguiente

Lista
-Se extrae el primer elemento de la lista
-Se puede insertar un elemento
-Se pueden insertar varios elementos
-Debe existir una Lista con su cabeza
11 changes: 11 additions & 0 deletions examen.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,15 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "guard"
spec.add_development_dependency "guard-rspec"
spec.add_development_dependency "guard-bundler"
spec.add_development_dependency "coveralls"
# rest-client has an unbounded dependency on mime-types.
# mime-types 2.0 removes support for ruby 1.8.7 (gemspec requires ruby
# 1.9.2+), so we have to add an additional pin. 1.16 is chosen just becuase
# it's the version I had when I tested.
spec.add_dependency "mime-types", '~> 1.16'
spec.add_development_dependency "celluloid", '0.16.0'
spec.add_development_dependency "rest-client", '~> 1.7.2'
spec.add_development_dependency "listen"


end
5 changes: 4 additions & 1 deletion lib/examen.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
require "examen/version"
require 'examen/version'
require 'examen/pregunta'
require 'examen/lista'
require 'examen/verdaderofalso'
require 'examen/eleccionsimple'
require 'examen/exam'
require 'examen/interfaz'

module Examen
# Your code goes here...
Expand Down
13 changes: 13 additions & 0 deletions lib/examen/eleccionsimple.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Examen
class EleccionSimple < Pregunta

def initialize arg
#attr_reader :enuncia2, :verdadero, :falso
#super(enunciado,verdadero,falso)
super(arg)
end


end

end
64 changes: 64 additions & 0 deletions lib/examen/exam.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
require "examen/lista"
module Examen
class Exam
attr_reader :preguntas, :respuescorrectas
def initialize (args)
@preguntas = args[:preguntas]
@respuescorrectas=args[:respuescorrectas]
end

def insertQuestion(question)
nodo=Nodo.new(question)
nodoInsertado = @preguntas.pushf(nodo)
nodoInsertado.value
end

def insertQuestion2(question)
nodo=Nodo.new(question)
nodoInsertado = @preguntas.push(nodo)
nodoInsertado.value
end


def compresp(resp)
correctas=0
i=0
n=0

while n < 5 do
if @respuescorrectas[i] == resp[i]
correctas+=1
end
i+=1
n+=1
end
if correctas < (i/2)+1
mensaje = "Ha suspendido el examen: #{correctas}/#{i}"
else
if correctas == i
mensaje = "Su nota es: Sobresaliente 10"
else
mensaje = "Ha aprobado el examen: #{correctas}/#{i}"
end
end
mensaje
end


def preguntas
@preguntas
end


def respu
@respuescorrectas
end


end
end





17 changes: 17 additions & 0 deletions lib/examen/examen.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module Examen

class Examen < Lista

def initialize

super(nodo)

end





end

end
56 changes: 56 additions & 0 deletions lib/examen/interfaz.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
require 'examen/exam'
require 'examen/lista'
module Examen

class Interfaz

attr_reader :examen
def initialize(args)
@examen=args[:examen]


end

def to_s
aux = @examen.inicio
respuesta = ""
respuesta += aux.value.to_s
respuesta += "\n"
while (aux != @examen.fin) do
aux = aux.next
respuesta += aux.value.to_s
respuesta += "\n"
end
respuesta
end

def invertir
aux = @examen.fin
respuesta = ""
respuesta += aux.value.to_s
respuesta += "\n"
while (aux != @examen.inicio) do
aux = aux.prev
respuesta += aux.value.to_s
respuesta += "\n"
end
respuesta
end



def invertirfuncional(arr)
#aux=%W(#{arr})
#lambda {|a| a.map(&:reverse) }.call(aux.reverse)
arr2=Array.new
arr.reverse_each do |z|
arr2.push(z)
end
arr2
end

end

end


27 changes: 22 additions & 5 deletions lib/examen/lista.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@


include Enumerable
Nodo =Struct.new(:value, :next, :prev)



class Lista
Nodo =Struct.new(:value, :next, :prev)
include Enumerable

def initialize(nodo)
@inicio=Nodo.new(nil)
@fin=Nodo.new(nil)
Expand Down Expand Up @@ -61,4 +60,22 @@ def fin

@fin
end


def respuesta
@respuesta
end


def each(&block)
tempo = @inicio
while tempo != nil
block.call(tempo)
#yield tempo.value
tempo=tempo.next
end
end


end

33 changes: 14 additions & 19 deletions lib/examen/pregunta.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'pry'
module Examen

class EleccionSimple #< Struct.new("Pregunta", :enunciado , :respuesta, :falsas)
class Pregunta #< Struct.new("Pregunta", :enunciado , :respuesta, :falsas)
#use a class to define behavior, together with a Struct that defines the data to which the class should be initialized.
#----------------------------------------------------------
#----------------------------------------------------------
Expand All @@ -10,33 +10,20 @@ class EleccionSimple #< Struct.new("Pregunta", :enunciado , :respuesta, :falsas)
#----------------------------------------------------------
#----------------------------------------------------------

attr_reader :enunciado, :respuesta,:falsas
attr_reader :valor, :enunciado, :respuesta,:falsas
include Comparable
def initialize(arg)
@valor=arg[:valor]
@enunciado=arg[:enunciado]
@respuesta=arg[:respuesta]
@falsas=arg[:falsas]

end

# def empu(unapreg)
# @pregunta.push(unapreg)
# end

# def saca(arg)
# retorna = @pregunta.to_a[arg]
# retorna
# end


# class Person < Struct.new(:age, :gender)
# def to_s
# "Age: #{age}; Gender: #{gender}"
# end
# end


def extresp

"RESPUESTAS : #{@respuesta}, #{@falsas}"

end

def to_s
Expand All @@ -47,6 +34,14 @@ def to_s
def preg
"PREGUNTA : #{@enunciado}"
end

def <=> other
#return nil unless other.is_a? Examen
self.valor <=> other.valor
end



end

end
4 changes: 1 addition & 3 deletions lib/examen/verdaderofalso.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
module Examen
class Verdaderofalso < EleccionSimple
class Verdaderofalso < Pregunta

def initialize arg
#attr_reader :enuncia2, :verdadero, :falso
#super(enunciado,verdadero,falso)
super(arg)
end

Expand Down
Loading

0 comments on commit 1a25fe0

Please sign in to comment.