10 POINTS |
Problem 2. A package company keeps track of three kinds of packages: regular, express, and overnight. The company uses three different classes of data to represent the relevant information:
(define-struct regular (zip)) (define-struct express (zip zap zoom)) (define-struct overnight (zip zap)) ;; A Package is one of: ;; -- (make-regular TenNumber) ;; -- (make-express TenNumber Symbol Number) ;; -- (make-overnight TenNumber Symbol) ;; A TenNumber is a Number between 1 and 9999 (inclusive).
This problem consists of three, independent parts. In order to solve one part, you do not need to know the solution for any other part.
Name the constructor, selectors, and predicate that the structure definition for regular introduces.
Solution:
make-regular regular-zip regular? ; [PT 1, for all]
Make up three examples for Packages, one from each subclass.
Solution:
;[PT 3, one each] (make-regular 890) (make-express 9999 'High -10) (make-overnight 1 'Low)