Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. (20 Points) Provide data definitions for both a Book and a Date. Include both the define-structs and at least three examples for each data
1. (20 Points) Provide data definitions for both a Book and a Date. Include both the define-structs and at least three examples for each data definition. When creating a struct, the order of the fields in the constructor should match the order given in the descriptions above. The names of the fields in the struct don't matter, but the order does. For example, the fields of the struct for a Book should be the title, author, genre, length, publication date, and sales, in that order. Failure to define the fields in the given order will cause our auto-tester to fail, and you will lose points. Your struct for a Date should have 3 fields, one for the year, one for the month, and one for the day, in that order. Each field in a Date is of type Natural. 2. (15 Points) In a comment in the Definitions Window, state the signatures of all the procedures that are created by Racket for your Book struct. 3. (20 Points) Write a function imaginative-fiction? which consumes a Book and returns true if its genre is "mystery", "science fiction", or "fantasy" and returns false otherwise. 4. (20 Points) Write a function combined-length which consumes two Books and produces a Number. The number produced is the sum of the lengths of the two books. 5. (20 Points) Write a function update-sales which consumes a Book and a Number, and produces a Book. The Book that is produced is the same as the original except that its sales has been replaced by the new amount. 6. (25 Points) Write a function since? which consumes a Book and a Date, and produces a Boolean. The function produces true if the given Book was published after the given Date, and returns false otherwise
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started