(define-struct tiger (name length sells)) ;; a Tiger is a (make-tiger String Natural Product) ;; inerp: a tiger where ;; name is the tiger's name ;; length is the length of the tiger (in feet) ;; sells is a Product that the tiger sells (define-struct product (item company)) ;; a Product is a (make-product String String) ;; interp: a product where ;; item is the name of the item ;; company is the name of the company that manufactures the item ;;; fcn-for-product: Product -> ;;; ;(define (fcn-for-product a-prod) ; (... (product-item a-prod) ; (product-company a-prod))) ; ;; examples (define TONY (make-tiger "Tony" 3 (make-product "Frosted Flakes" "Kellogg's"))) ;; template ;;; fcn-for-tiger: Tiger -> ;;; ;(define (fcn-for-tiger a-tiger) ; (... (tiger-name a-tiger) ; (tiger-length a-tiger) ; (fcn-for-prod (tiger-sells a-tiger)))) ;; sells-gas?: Tiger -> Boolean ;; consumes a tiger and produces true if the item the tiger sells is gas (define (sells-gas? a-tiger) (is-it-gas? (tiger-sells a-tiger))) ;; test cases (check-expect (sells-gas? (make-tiger "Tony" 3 (make-product "Frosted Flakes" "Kellogg's"))) false) (check-expect (sells-gas? (make-tiger "Joe" 4 (make-product "gas" "Exxon"))) true) ;; is-it-gas?: Product -> Boolean ;; returns true if the item is gas (define (is-it-gas? a-prod) (string=? (product-item a-prod) "gas")) ;; test (check-expect (is-it-gas? (make-product "cereal" "Kellogg's")) false) (check-expect (is-it-gas? (make-product "gas" "Exxon")) true)