-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPregunta02mta2.rb
44 lines (35 loc) · 1013 Bytes
/
Pregunta02mta2.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#Desarrollar un subprograma que permita calcular el volumen de una piscina
def volumen_piscina(largo,ancho,profundidad)
volumen_total = largo * ancho * profundidad
return volumen_total.round(2)
end
#Desarrollar un subprograma que permita definir si una persona es mayor de edad o no
#el programa retornará true si es mayor de edad o false si no lo es.
def mayor_de_edad(edad)
if edad < 18
return false
else
return true
end
end
#--- zona de test ----
def test_volumen_piscina
print validate(10000.0, volumen_piscina(10.0,100.0,10.0))
print validate(3000.0, volumen_piscina(30.0,10.0,10.0))
end
def test_mayor_de_edad
print validate(true, mayor_de_edad(18))
print validate(false, mayor_de_edad(12))
print validate(true, mayor_de_edad(22))
end
def validate (expected, value)
expected == value ? "." : "F"
end
def test
puts "Test de prueba del programa"
puts "---------------------------"
test_volumen_piscina
test_mayor_de_edad
puts " "
end
test