Advertisement
cardel

Solución ejercicio taller

Dec 7th, 2019
1,312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 3.39 KB | None | 0 0
  1. (define-struct info-hotel (nombre numNoches costoNoche infoHabitacion))
  2. (define-struct info-habitacion (numCamas numBaños numDuchas))
  3.  
  4. (define-struct info-transporte (ciudadOrigen ciudadDestino valorTiquete numPersonas otros))
  5. (define-struct otros-viaje-info (aeropuerto niños-ancianos))
  6.  
  7. (define-struct info-guia (ciudad nombrePlan numSitios valorSitio))
  8.  
  9. (define-struct info-plan (valorHotel valorTransporte valorPlanGuia valorTotal))
  10.  
  11. ;;Autor: Carlos A Delgado
  12. ;;Fecha 07 de dic 2019
  13. ;;Contrato: calcular-hotel: info-hotel -> numero
  14. (define (calcular-hotel info-h)
  15.   (* (info-hotel-costoNoche info-h) (info-hotel-numNoches info-h)
  16.      (if (or (> (info-habitacion-numCamas (info-hotel-infoHabitacion info-h)) 2)
  17.              (> (info-habitacion-numBaños (info-hotel-infoHabitacion info-h)) 3)
  18.              (> (info-habitacion-numDuchas (info-hotel-infoHabitacion info-h)) 2))
  19.          1.25
  20.          1
  21.          )
  22.      )
  23.   )
  24.  
  25. ;;Autor: Carlos A Delgado
  26. ;;Fecha: 07 de Dic 2019
  27. ;;Contrato: calcular-costo-transporte: info-transporte -> numero
  28. (define (calcular-costo-transporte info-t)
  29.   (*
  30.    (+
  31.     (* (info-transporte-valorTiquete info-t) (info-transporte-numPersonas info-t))
  32.     (otros-viaje-info-aeropuerto (info-transporte-otros info-t))
  33.     (otros-viaje-info-niños-ancianos (info-transporte-otros info-t))
  34.     )
  35.    (if
  36.     (> (info-transporte-numPersonas info-t) 5)
  37.     0.6
  38.     1
  39.     )
  40.    )
  41.   )
  42.  
  43. ;;Autor: Carlos A Delgado
  44. ;;Fecha: 07 de Dic de 2019
  45. ;;Contrato: calcular-valor-guia: info-guia -> numero
  46. (define (calcular-valor-guia info-g)
  47.   (*
  48.    (info-guia-numSitios info-g)
  49.    (info-guia-valorSitio info-g)
  50.    (if (> (info-guia-numSitios info-g) 4) 1.2 1)
  51.    )
  52.  )
  53.  
  54.  
  55. ;;Autor: Carlos A Delgado
  56. ;;Fecha: 07 de Dic 2019
  57. ;;Contrato: calcular-valor-plan: info-hotel, info-transporte, info-guia -> info-plan
  58. ;;Propósito: Es presentar en una estructura el costo total de un viaje turistico
  59. ;;Ejemplos.
  60. (define (calcular-valor-plan info-h info-t info-g)
  61.   (make-info-plan
  62.    (calcular-hotel info-h)
  63.    (calcular-costo-transporte info-t)
  64.    (calcular-valor-guia info-g)
  65.    (+ (calcular-hotel info-h) (calcular-costo-transporte info-t) (calcular-valor-guia info-g))
  66.    ))
  67.  
  68. ;;Pruebas
  69.  
  70. (define hotel
  71.   (make-info-hotel
  72.    "Tulua city"
  73.    2
  74.    20000
  75.    (make-info-habitacion 2 4 5)))
  76.  
  77. (define transporte
  78.   (make-info-transporte
  79.    "Cali"
  80.    "Cartagena"
  81.    120000
  82.    6
  83.    (make-otros-viaje-info 4000 6000)))
  84.  
  85.  
  86. (define guia
  87.   (make-info-guia
  88.    "Cartagena"
  89.    "Plan FDP"
  90.    5
  91.    40000
  92.    ))
  93.  
  94. (calcular-valor-plan hotel transporte guia)
  95.  
  96.  
  97. ;;Autor: Carlos A Delgado
  98. ;;Fecha: 07 de Diciembre de 2019
  99. ;;Contrato: desplegar-informacion: info-plan, string -> string
  100. ;;Propósito: Emitir una información comprensible para un usuario (persona)
  101. ;;(define-struct info-plan (valorHotel valorTransporte valorPlanGuia valorTotal))
  102. ;;Ejemplos
  103. ;
  104. (define (desplegar-informacion plan nombre)
  105.   (string-append
  106.    "Señor "
  107.    nombre
  108.    " su plan tiene un costo total de "
  109.    (number->string (info-plan-valorTotal plan))
  110.    ", en total son "
  111.    (number->string (info-plan-valorHotel plan))
  112.    ", en transporte son "
  113.    (number->string (info-plan-valorTransporte plan))
  114.    " y su plan de visita "
  115.    (number->string (info-plan-valorPlanGuia plan))
  116.    ", gracias por cree en nosotros :)"
  117.    )
  118.   )
  119.  
  120. (desplegar-informacion (calcular-valor-plan hotel transporte guia) "Carlos")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement