;======== ; Fall 2026 - CS 111 ; Week 3 Lab Exercise - save as lab3.rkt ; ; date: 2026-09-11 ;======== ;----- ; this file will use definitions and functions from these modules: (require 2htdp/image) (require 2htdp/universe) ;======== ; NOTE: ; * To receive credit for this lab exercise, you must: ; * be present during your lab section, ; either in BSS 313 or in the lab Zoom session, ; based on your lab section ; * participate appropriately in a pair (see below), ; either in BSS 313 or in a Zoom breakout room ; ;======== ; 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, and save as: ; ; lab3.rkt ; ; 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! ; ******** ; ; * remember: it is a class style standard to put a ; BLANK LINE between each comment-block and an expression ; following it ; ; 3. SAVE the contents of your definitions window frequently ; as you are working, to the driver's Google Drive, ; using a file name of lab3.rkt. ; ; 4. RUN the resulting file frequently as you are working, ; clicking the Run button in the top-right corner ; each time, looking over your expressions' values in ; the Interactions window (the bottom window), and fixing ; any errors that arise. ; ; (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 Learning Assistants/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! ; ; 5. When you are done, use Gmail to MAIL a copy of the ; resulting filled-in lab3.rkt file to BOTH of you ; ; 6. And, EACH of you should SUBMIT this file to Canvas BEFORE you ; leave lab. ; ; 7. REMEMBER to also answer the ; "Week 3 Lab Exercise - Pair-Programming Peer Review Survey" ; in Canvas, posted along with this lab exercise, by ; 11:59 pm TONIGHT (Friday, September 11) ;======== ;===== ; Leave a blank line, and then put COMMENT(s) containing BOTH ; of your names (include first AND last names) ;======== ; PROBLEM 1 - Define some scene-related named constants, ; and write some expressions of type scene ; ; (so, NO design recipe steps are needed here!) ;======== ;----- ; 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 ; for example: (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. ; for example: (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 ; for example: (= (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 ; for example: (= (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 to Canvas ; BEFORE you leave lab. ; ; * ALSO answer the ; "Week 3 Lab Exercise - Pair-Programming Peer Review Survey" ; in Canvas, posted along with this lab exercise, by ; 11:59 pm TONIGHT (Friday, September 11) ;=====