;======== ; Fall 2024 - CS 111 ; Week 3 Lab Exercise ; ; date: 2024-09-13 ;======== ; make the definitions and functions from these modules available ; in this file (require 2htdp/image) (require 2htdp/universe) ;======== ; REMINDER: Pair-programming: ; * TWO students working at ONE computer ; * ONE student, student A, OPENS a copy of this file in ; DrRacket ; * the OTHER student, student B, says what to type, and student A ; types it into this file ; * BOTH students should be looking at the shared computer screen, ; and discussing concepts/issues along the way ;======== ;======== ; USING pair-programming: ; 1. COPY and PASTE the contents of this file into a ; DrRacket Definitions window ; 2. ADD comments and expressions TO THIS as specified below ; (one student saying what to type, the other student typing it ; into DrRacket) ; ; ******** ; * DO NOT DELETE THE COMMENTS! They speed up grading! ; ******** ; ; 3. RUN the resulting file frequently along the way, fixing ; any errors that arise (and SAVE the definitions window ; to the driver's Google Drive, say as lab3.rkt) ; ; (Need help with an error? Or just have a question? ; * If needed, comment out the line(s) with an ; error in the meantime, putting ; at the ; beginning of each such line ; * Let the lab instructor know if you have a ; question ; * Note that if they are helping others, it ; might be a while until they can get to you. ; Try to work on later problems while you ; wait, and it is also fine for pairs to help ; each other!) ; ; 4. When you are done, use Gmail to MAIL a copy of ; the resulting filled-in lab3.rkt file to BOTH ; of you ; 5. And, EACH of you should SUBMIT this file on ; Canvas ;======== ;===== ; Leave a blank line, and then put COMMENT(s) ; containing BOTH of your names: ;======== ; PROBLEM 1 - Define some scene-related named ; constants, and write some expressions ; of type scene ; (so, NO design recipe steps needed ; here! 8-) ) ;======== ;----- ; 1 part a ; ; You are going to create some scene instances for ; Problem 2 of today's lab exercise. ; ; Decide how wide and high you want your scenes to be; ; define named constants SC-WIDTH and SC-HEIGHT ; to be these values. ;----- ; 1 part b ; ; Define a named constant BACKDROP of type scene ; whose size is SC-WIDTH by SC-HEIGHT. ; (It is YOUR CHOICE whether this scene is an ; empty scene or has something in it.) ;----- ; 1 part c ; ; Use your named constant BACKDROP in a ; place-image compound expression, ; adding an image of your choice at x and y ; coordinates of your choice to BACKDROP ;======== ; PROBLEM 2 - write a function number-scene ;======== ; *HINT*: function number->string expects a ; number, and returns that number as a string (string=? (number->string 13) "13") ; *HINT*: function text expects a string, ; font size, and color, and returns an image ; version of that string in that font size ; and color. (text "Howdy" 55 "darkgreen") ;----- ; 2 part a ; ; Using the DESIGN RECIPE, design a function ; number-scene that expects a number, and returns ; a scene displaying that number. ; (the user of this function gives JUST the number they ; want to see in a scene -- you as the programmer ; get to decide on the size and color it will ; always be displayed using, and where in the ; scene it will always be placed.) ; It should use Problem 1's named constants. ;----- ; 2 part b ; ; Write at least one compound expression whose operation ; is your function number-scene, so you can see its ; actual result in the Interactions window when this ; is run. ;======== ; PROBLEM 3 - write a big-bang expression using ; add1 and number-scene ;======== ; REMINDER: add1 expects a number, and returns ; that number with 1 added to it (= (add1 13) 14) ; Write a big-bang expression with ; * a first argument that is a number of your ; choice ; * a second argument that is (on-tick add1) ; * a third argument that is (to-draw number-scene) ; ; SEE what this displays! ;======== ; PROBLEM 4 - write a big-bang expression using ; sub1 and number-scene ;======== ; REMINDER: Racket also has a sub1 function, that ; expects a number, and returns that number with ; 1 subtracted from it (= (sub1 13) 12) ; Write a big-bang expression with ; * a first argument that is a number of your choice ; * a second argument that is (on-tick sub1) ; * a third argument that is (to-draw number-scene) ; ; SEE what this displays! ; (NOTE: now that you have TWO big-bang expressions, ; you'll have to CLOSE the first big-bang ; expression's World window before the second ; big-bang expression will start!) ;===== ; Remember: once you have Run these and are satisfied ; with them, ; * Use Gmail to EMAIL copies of this file lab3.rkt ; to BOTH of you ; ; * BOTH of you should submit this file on Canvas ;=====