Está en la página 1de 3

class Costeo

attr_accessor :mano_obra
def initialize (mano_obra)
@mano_obra = mano_obra
end

def costo
end
end

class Casa < Costeo


attr_accessor :codigo, :puertas, :ventanas, :pared, :techo,
def initialize (mano_obra, codigo, puertas, ventanas, pared, techo)
super (mano_obra)
@codigo, @puertas, @ventanas, pared, @techo = codigo, puertas,
ventanas, pared, techo
end
def costo
return ((pared^2)*80+(techo^2)*90+puertas*250+ventanas*100)
end
end

class Edificio < Costeo


attr_accessor :codigo, :puertas, :ventanas, :pared, :techo, :pisos
def initialize (codigo,puertas,ventanas,pared,techo,pisos)
super (mano_obra)
@codigo, @puertas, @ventanas, pared, @techo, @pisos = codigo, puertas,
ventanas, pared, techo, pisos
end

def costo
return ((pared^2)*50+(techo^2)*80+puertas*200+ventanas*60)*pisos
end
end

class Reporte
attr_accessor :mobiliaria
def initialize ()
@mobiliaria = Array.new
end

def agregarMobiliaria (aux)


mobiliaria.push (aux)
end

def cabecera
puts
"==================================================================================
============="
puts "CODIGO\t\t\ PUERTAS\t\t\ VENTANAS\t\t\ PARED\t\t\ TECHO\t\t
PISOS\t\t MANO DE OBRA\t\t TIPO"
puts
"==================================================================================
============="
end

def imprimir (x)


puts x.codigo + "\t" +
x.puertas + "\t\t" +
x.ventanas + "\t\t" +
x.pared + "\t\t\t" +
x.techo + "\t\t\t" +
x.pisos + "\t\t\t" +
x.mano_obra + "\t\t\t" +
x.class.name
end

def listarTodos
cabecera
for x in mobiliaria
imprimir (x)
end
end

def buscarCodigo(aux)
total = 0
for x in mobiliaria
if x.codigo == aux
imprimir (x)
end
end
end

def buscarManoObra(aux)
cabecera
for x in mobiliaria
if x.mano_obra == aux
imprimir (x)
end
end

def cotizacion
total = 0
for x in mobiliaria
if x.costo > total
total = x.costo
end
end
end
end

def buscarCosteoCasa (aux)


tot = 0
for x in mobiliaria
if x.class.name == aux
total = x.costo
end
end
end

def buscarCosteoEdificio(aux)
tot = 0
for x in mobiliaria
if x.class.name == aux
total = x.costo
end
end
end
objP01 = Costeo.new("s/.1500000")
objP02 = Costeo.new("s/.1400000")
objP03 = Costeo.new("s/.1800000")
objP04 = Costeo.new("s/.1900000")

obj1 = Casa.new("0ABC1", 15, 18, 18, 22, objP01)


obj2 = Casa.new("0ABC2", 36, 10, 28, 13, objP02)
obj3 = Casa.new("0ABC3", 17, 18, 15, 27, objP03)
obj4 = Casa.new("0ABC4", 12, 15, 19, 28, objP04)

obj5 = Edificio.new("0ABC5", 2, 15, 29, 18)


obj6 = Edificio.new("0ABC6", 6, 17, 39, 24)
obj7 = Edificio.new("0ABC7", 8, 19, 49, 26)
obj8 = Edificio.new("0ABC8", 9, 21, 19, 29)

objReporte = Reporte.new
objReporte.agregarMobiliaria (obj1)
objReporte.agregarMobiliaria (obj2)
objReporte.agregarMobiliaria (obj3)
objReporte.agregarMobiliaria (obj4)
objReporte.agregarMobiliaria (obj5)
objReporte.agregarMobiliaria (obj6)
objReporte.agregarMobiliaria (obj7)
objReporte.agregarMobiliaria (obj8)
objReporte.agregarMobiliaria (obj9)

objReporte.listarTodos
puts
"==========================================================================="
objReporte.buscarCasa("0ABC1")
puts
"==========================================================================="
objReporte.buscarEdificio ("0ABC7")
puts
"==========================================================================="
objReporte.buscarCosteoCasa(Casa)
puts
"==========================================================================="
objReporte.buscarCosteoEdificio(Edificio)

También podría gustarte