#lang scheme

(require scheme/class)

(define pez%
  (class object%
    (init-field
     peso)
    (field
     (peso-actual peso))
    ;;
    (define get-peso
      (lambda ()
        peso-actual))
    (define crecer; set-current_size
      (lambda (cant)
        (set! peso-actual (+ peso-actual cant))))
    (define comer
      (lambda (otro-pez)
        (crecer (send otro-pez get-peso))))
    ;;
    (public get-peso crecer comer)
    ;;
    (super-new)
    ))

;;; subclases
(define pez-limon
  (lambda (%)
    (class %
      (inherit comer)
      (define comer-mas
        (lambda (pez1 pez2)
          (comer pez1);llamada a un metodo de pez%
          (comer pez2)))
      (public comer-mas)
      (super-new)) ))

(define pez-verde
  (lambda (%)
    (class %
      (override crecer)
      (define crecer 
        (lambda (cant)
          (super crecer (* 3/4 cant))))
      (super-new)) ))

(define pez-naranja
  (lambda (%)
    (class %
      (override crecer)
      (define crecer
        (lambda (cant)
          (super crecer (* 2/3 cant))))
      (super-new)) ))

(define pez-naranja% (pez-naranja (pez-verde (pez-limon pez%))))

(define q (make-object pez% 5))

(define w (make-object (pez-limon pez%) 10))

(define z (make-object (pez-verde pez%) 20))

(define x (make-object pez-naranja% 30))

