6.6

Assignment 3

home work!

Programming Language BSL

Due Date Thursday 9/20 at 9pm

Purpose To design a small program using conditional data.

Expectations
  • You should submit a single .rkt file containing your responses to all exercises via the Handin Server. We accept NO email submissions.

  • You are only allowed to use the language specified at the top of this page: failure to do so will result in a 0.

  • All elements of the design recipe are expected. Data definitions should have associated interpretations, examples, and templates. Functions should have signatures, purpose statements, tests, and code.

  • Note that there are few exceptions to these rules, such as main functions not being able to be tested.

  • Be sure to use helper functions when appropriate to keep code clear.

Graded Exercises

Check out this article for more info on crypto names if you’re curious.

; A CryptoName is one of:
; - "Alice"
; - "Bob"
; - "Carol"
; and represents the collection of names used in crypotography narratives

Exercise 1 Define three distinct examples of CryptoNames.

Exercise 2 Design the template for a function that takes in a CryptoName.

Check out the docs on on-key for the definition of a KeyEvent.

Exercise 3 Design a function which, given a CryptoName, backup, and a KeyEvent, ke, outputs the CryptoName whose first character is the capitalized version of ke (so if the key event is "a", the function produces "Alice", "b" produces "Bob", etc.).

If there is no such match, the function should return the original CryptoName, backup. Note that this last case also applies to "A", "B", etc.

Exercise 4 Design a function which is given a CryptoName and a KeyEvent. If the key event is "right" the function outputs the next name in the sequence (alice->bob->carol->alice...). If the key event is the first letter of one of the names, it outputs the corresponding name (e.g. the key event "a" would cause the function to produce "Alice").

If neither of these apply, the function outputs the provided CryptoName. Note that this last case also applies to "A", "B", etc.

Exercise 5 Design a function which, given a CryptoName, draws it on an empty-scene. Use constants for your text as well as your background scene.

Exercise 6 Design a function main/crypto which takes in a CryptoName (the first name you want to display) and launches a big-bang program that lets someone cycle through the crypto names by pressing the right arrow key as well as jumping to crypto names by inputting the lowercase version of the first character in their name. The output of the function should be the CryptoName on display when the program ends.