;========
; Fall 2024 - CS 111
; Week 4 Lab Exercise
;
; date: 2024-09-20
;========

; make the definitions and functions from these modules available
;     in this file

(require 2htdp/image)
(require 2htdp/universe)

;========
; 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, saving the 
;    Definitions window frequently, say as lab4.rkt
; 4. When you are done, use Gmail to MAIL a copy of 
;    the resulting filled-in lab4.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 - READING and MODIFYING a function with a cond
;             expression
; [adapted from
;    http://web.cs.wpi.edu/~cs1101/a05/Labs/lab1.html,
;    as found from EngageCSEdu]
;========

;--------
; Problem 1 - PART 1
;--------
; below is a function definition, BUT, in the given lab exercise
;    file, its tests/check- expressions are COMMENTED OUT.
;
; *** RUN THIS AS IT IS RIGHT NOW ***
;
;     YOU SHOULD SEE THE FOLLOWING:
;     *   NO expression values in the Interactions window
;         (because this only defines the function at this point)
;
;     *   the function body appears with a DARK background
;         with ORANGE letters [***IF*** you are not running
;                              in dark mode]
;         *   IMPORTANT: this is DrRacket's way of HIGHLIGHTING
;             these expressions, to say that they were NOT EXECUTED
;             in this latest Run
;         *   this CAN mean (as it does here) that you are missing
;             tests/check- expressions for such a function
                                        
;-----
; signature: babel-greet: string -> string
; purpose: expects the name of a language, Spanish, French,
;          Japanese, or English, and returns a suitable
;          greeting in that language. 
;          Returns "Don't know" if given a language it
;          does not recognize.

(define (babel-greet lang)
    (cond
        [(string=? lang "Spanish") "Hola"]
        [(string=? lang "French") "Bonjour"]
        [(string=? lang "Japanese") "Konnichiwa"]
        [(string=? lang "English") "Hello"]
        [else "Don't know"]
    )
)

; at beginning of lab exercise: tests below are commented
;    out, to make a point described above!
;
;(check-expect (babel-greet "Spanish") "Hola")
;(check-expect (babel-greet "French") "Bonjour")
;(check-expect (babel-greet "Japanese") "Konnichiwa")
;(check-expect (babel-greet "English") "Hello")
;(check-expect (babel-greet "Texan") "Don't know")


;--------                                             ^
; Problem 1 - PART 2                                   \
;--------                                               \
; *** ADD the compound expression: ***                   \
;                                                         \
; (babel-greet "Spanish")                                  \
;                                                           |
; after babel-greet's commented-out check- expressions above^
;
; *** RUN THIS AGAIN ***
;
;     YOU SHOULD SEE THE FOLLOWING:
;     *   the 1st branch in babel-greet is NOT highlighted now --
;         it *was* executed in this latest run.
                    
;--------
; Problem 1 - PART 3
;--------
; *** REMOVE the ;'s before each check-expect for babel-greet ***
; ***    (that is, UNCOMMENT the check-expect expressions)    ***
;
; *** RUN THIS AGAIN ***
;
;     YOU SHOULD SEE THE FOLLOWING:
;     *   NO expressions in babel-greet are highlighted now --
;         all *WERE* executed in this latest run.

;--------
; Problem 1 - PART 4
;--------
; *   ABOVE, ADD an expression calling babel-greet with
;     argument "Wiyot"
;     *   RUN this, see what babel-greet returns
;
; *   According to https://www.wiyot.us/DocumentCenter/View/112
;     =========================================
;     *** one Wiyot greeting is "Ha’wa’lou" ***
;     =========================================
;
; *   ABOVE, ADD a test/check-expect that should PASS
;     if babel-greet is able to properly handle an
;     argument of "Wiyot"
;
; *   then MODIFY babel-greet so that this test PASSES,
;     and babel-greet DOES return an appropriate greeting
;     for "Wiyot"

;========
; PROBLEM 2 - write a function size->quant
;========
; Consider a situation where drink sizes are expressed with the
;     following words (from:
;https://www.eater.com/2011/1/17/6701687/starbucks-to-launch-a-31-oz-big-gulp-of-coffee-the-trenta):
; size name:  "short"  "tall"  "grande"  "venti"  "trenta"
; # ounces:     8       12      16        20       31
;
; Using the DESIGN RECIPE, design a function size->quant that
;     expects the *name* of one of these drink sizes, and
;     returns just the *number* of ounces you get for that
;     drink size.
;     (that is, for example, if you call it with an argument of "short", 
;     it returns just the number 8)
; But what if someone calls this with a size name not in this list?
;     Your function should return 0 in that case.
;
; (NOTE: this is what HtDP/2e Section I - Chapter 4
;     calls ENUMERATION-style data, listing out the
;     separate possible values.)
; Since there are 5 possible, separate values,
;     plus the user may give a "bad" value,
; MAKE SURE sure you include
;     AT LEAST SIX appropriate check-expressions/tests
;     for size->quant










;========
; PROBLEM 3 - write a function judge-carbs
;========
; Someone has decided that they want to judge a food as
;       low-carbohydrate if it has less than or equal to 10 grams
;       of carbohydrates per serving.
; And, if  > 10 grams and <= 20 grams, they want to judge it as
;       moderate-carbohydrate,
; and if > 20 grams, they want to judge it as high-carbohydrate.
;
; Using the DESIGN RECIPE, design a function judge-carbs that
;    expects the *number* of carbohydrates some food has in
;    a serving, and returns whether, based on the above, it
;    is "lo-carb", "mod-carb", or "hi-carb".
;    (that is, for example, if you call it with an argument of 15,
;    it returns just the string "mod-carb")
;
; (NOTE: this is what HtDP/2e Section I - Chapter 4
;     calls INTERVAL-style data, describing the data as ranges
;     of numbers.)
; Since there are 3 intervals,
;     and thus two BOUNDARIES between those 3 intervals,
; MAKE SURE you include
;    AT LEAST FIVE appropriate check-expressions/tests
;    for judge-carbs










;=====
; Remember: once you have Run these and are satisfied with them,
; *   Use Gmail to EMAIL copies of this file to BOTH of you
;
; *   BOTH of you should submit this file on Canvas
;=====