;======== ; Fall 2026 - CS 111 ; Week 2 Lab Exercise - save as lab2.rkt ; ; date: 2026-09-04 ;======== ;----- ; this file will use definitions and functions from this module: (require 2htdp/image) ;======== ; 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: ; 0. If needed, use the DrRacket "Language" menu to choose the language ; "Beginning Student", and click the Run button in the top-right ; corner to set that as your language. ; ; 1. COPY and PASTE the contents of this file into a DrRacket ; Definitions window, and save as: ; ; lab2.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 lab2.rkt. ; * (You can use the File menu's "Save Definitions" command, or ; use its shortcut of typing the keys control-s or command-s.) ; ; 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 lab2.rkt file to BOTH of you ; ; 6. And, EACH of you should SUBMIT this file on Canvas ; BEFORE you leave lab. ;======== ;===== ; Leave a blank line, and then put COMMENT(s) containing BOTH ; of your names (include first AND last names) ;======== ; PROBLEM 1 - DEFINING and USING named constants ; ; (you only need signatures and purpose statements for FUNCTIONS -- ; so, NO design recipe steps are needed here!) ;======== ;----- ; 1 part a ; Remember: LOOKY-IMG, MAX-SAFE-TEMP, and DAYGLO-HEX are examples of ; named constants in the Week 2 posted examples ; ; Define a named constant PAIR-NAMES of type string ; whose value is your names. ; Now write the now-simple-expression PAIR-NAMES, ; and when you run this file, ; you should see PAIR-NAMES now has that value. ;----- ; 1 part b ; FUN FACT: function string-length expects a string, and returns the ; number of characters in that string. ; ; Write a compound expression using PAIR-NAMES whose value will be ; the number of characters in PAIR-NAMES ;----- ; 1 part c ; Consider the functions overlay and text ; * their signatures and purpose statement comments ; are given in the "Some DrRacket Tidbits" handout ; ; * (and of course they are described in the Racket ; Documentation for 2htdp/image, also) ; ; Write a SINGLE compound expression meeting these requirements: ; * it uses overlay ; ; * it uses text ; ; * it uses at least one other image operation(s) that ; you choose ; ; * it uses your named constant PAIR-NAMES ; ; * its value will be an image of your choice with an ; image-version of PAIR-NAMES' value centered upon it ;----- ; 1 part d ; Define a named constant of type image meeting these requirements: ; * give it a nicely-descriptive name written in ; all-uppercase ; ; * the named constant's value should be the result of ; a compound expression of type image ; ; * that compound expression should use at least two ; different functions from 2htdp/image ; Now write your new named constant as a simple expression, ; and when you run this file, ; you should see that your new named constant ; has that image value. ;----- ; 1 part e ; REMINDER: function image-width expects an image, and returns the ; width of that image in pixels. ; ; Write a compound expression ; using the named constant you defined in 1 part d, ; whose value will be the width of ; your named constant image in pixels. ;----- ; 1 part f ; REMINDER: Likewise, function image-height expects an image, and returns the ; height of that image in pixels. ; ; Write a compound expression ; using the named constant you defined in 1 part d, ; whose value will be the height of ; your named constant image in pixels. ;======== ; PROBLEM 2 - walking through the DESIGN RECIPE steps to ; design a function ;======== ;----- ; REMEMBER: these steps are demo'd in the posted Week 2 Lecture 2 ; examples, in 111lect02-2.rkt, designing function triple and ; cyan-star. ; ; AND: note that now there's a posted "graphic design recipe helper" ; on the course Canvas home page and public course web site, ; to remind you of these design recipe steps, also! ;===== ; and, one more REMINDER: string-append expects one or more string ; arguments, and returns a single string that is the values of ; all of those string arguments combined/appended together. ;----- ; FIRST, you THINK about the desired problem, and the kinds of values ; it involves. ; Assume you would like a function to give a friendly greeting to ; someone by name. Strings work well for representing names and ; greetings. ;----- ; 2 part a ; After further consideration, it is decided the function's name ; will be say-hi, and you want a name-specific greeting ; based on a name. ; COMPLETE an appropriate signature comment for this function: ; signature: ;----- ; 2 part b ; COMPLETE an appropriate purpose statement comment for this ; function: ; purpose: expects ; and returns ;----- ; 2 part c ; Write a function header for this function, giving a good descriptive ; name for its parameter, and FOR NOW put ... ; for its function body: ;----- ; 2 part d ; Write at least two check-expect expressions with two ; example expressions USING/TESTING your ; function-in-progress, with two DIFFERENT names: ;----- ; 2 part e ; Consider: how did you figure out the expected result for ; each of your tests? ; How could you do that in Racket? Where does your ; parameter fit in that? ; GO BACK UP to 2 part c, and NOW replace the ... in its ; function body with an expression, using the parameter, ; that will give the result ; desired. ;----- ; 2 part f ; Write at least one example call of your function here, so ; you can see its actual result in the Interactions window ; when this is run. ;----- ; Now SAVE your Definitions window, and click Run -- ; * Do your tests pass? ; ; * Does the resulting greeting for your ; example call from 2 part f look reasonable? ; ; If not, debug your function and its tests as needed. ; If so, you are done with this lab exercise. ;===== ; Remember: once you have Run these and are satisfied ; with them: ; * Use Gmail to EMAIL copies of this file lab2.rkt ; to BOTH of you ; ; * BOTH of you should submit this file on Canvas ; BEFORE you leave lab: ; * go to the course Canvas site (canvas.humboldt.edu, ; select your course CS 111) ; * click on "Modules" on the left-hand-side ; * scroll down to the "Lab Exercises" section ; * click the "Week 2 Lab Exercise" link ; * follow the Canvas instructions for uploading your ; Racket file. ;=====