;; The first three lines of this file were inserted by DrScheme. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "htdp-beginner-reader.ss" "lang")((modname 16.2.1) (read-case-sensitive #t) (teachpacks ((lib "testing.ss" "teachpack" "htdp"))) (htdp-settings #8(#t constructor repeating-decimal #f #t none #f ((lib "testing.ss" "teachpack" "htdp"))))) ; Worked exercise 16.2.1 ; An employee has three parts: name, id, and salary. ; The name is a string, while id and salary are numbers. (define-struct employee (name id salary)) ; make-employee : string(name) number(id) number(salary) -> employee ; employee-name : employee -> string ; employee-id : employee -> number ; employee-salary : employee -> number ; employee? : object -> boolean (check-expect (make-employee "Joe" 348 42995) (make-employee "Joe" 348 42995)) (check-expect (make-employee "Mary" 214 49500) (make-employee "Mary" 214 49500)) (define emp1 (make-employee "Bob" 470 36000)) (define emp2 (make-employee "Chris" 471 41000)) (check-expect (employee-name emp1) "Bob") (check-expect (employee-id emp2) 471) (check-expect (employee-salary emp2) 41000) (check-expect (employee-salary (make-employee "Mary" 214 49500)) 49500) (check-expect (employee? emp1) true) (check-expect (employee? "Mary") false) (generate-report)