;; 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.4.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.4.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 ; earns-over-100k? : employee -> boolean (define (earns-over-100k? emp) ; emp an employee ; (employee-name emp) a string ; (employee-id emp) a number ; (employee-salary emp) a number ; 100000 a fixed number (> (employee-salary emp) 100000) ) (define emp1 (make-employee "Bob" 470 36000)) (define emp2 (make-employee "Chris" 471 41000)) (check-expect (earns-over-100k? (make-employee "Phil" 27 119999)) true) (check-expect (earns-over-100k? (make-employee "Anne" 51 100000)) false) ; borderline case (check-expect (earns-over-100k? emp1) false) (generate-report)