Please test all your programs carefully and include all the test cases with your program. You should have at least 3 tests for each function, except the ones that produce an image or a scene.
Recall the function first-letter-A?
that
we wrote in
class. Here is our code:
Working from this example, perform the following steps:
;; (first-letter-A? str) -> boolean
;; str: string
;; consumes a string, returns true
;; if this string starts with a capital A, otherwise returns false
(define (first-letter-A? str)
(string=? (substring str 0 1) "A"))
(check-expect (first-letter-A? "AbC") true)
(check-expect (first-letter-A? "abC") false)
(check-expect (first-letter-A? "bcde") false)
;(check-expect (first-letter-A? "") false)
(check-expect (first-letter-A? "aaAAaaaa") false)
false
for it, as the commented out test case
indicates). You can use cond
or if
or
(better!) combine your conditions using boolean operations, such
as and, or, not
(either approach will get full credit if
works correctly). first-letter-a-or-A?
that returns true
if this string starts with "A" or "a"
and false
otherwise. It must return false
for an empty string. Make sure to write test cases and the description (contract) for your function.Modify the version 5 of the landing rocket example (figure 4 in Prologue) so that when the width of the scene is changed, the rocket is placed in the middle of the new scene.
Exercises 24 (5 points) and 25 (5 points) in Section 2.2.