Try the following:
play("<cccedddfeeddc---")play(">>>" + "cccedddfeeddc---")play("ccceddd>feedd<<<c---")
play
has been defined to let you change octaves: notes that follow the
>
character will be played at a higher pitch than the ones that precede
it; notes that follow <
will be played at a lower pitch. Multiple
octave-change marks cause a more dramatic change; for instance, the
second of the three examples above plinks out Ukko Nooa three octaves
higher.
Use the string operators +
and *
to pastiche the shark attack motif from the movie
Jaws. To be more specific, use the operators to form an expression
that evaluates to a string that contains exactly the following:
first, three <
characters to lower the
sounds that follow by three octaves (these
three at the beginning should be the
only <
s in the entire string); then
the pair of notes "ef" repeated sixteen
times; and finally
the upper-case pair of notes "EF" repeated
eight times.
In the REPL, try entering just the expression. Also try passing the expression
as a parameter to play
.
If you struggle with this assignment, the first thing is to check your double
quotes. Place each component string in quotation marks! It can also be a good
idea to print out the string you produced rather than playing it, so that you
can examine it visually. And remember that the lab sessions/Piazza/Telegram
are there to help you.
Reap the rewards by entering the String
-valued expression, operators and
all, below. Please enter just the expression, not a command that plays it.
Include the operators; don’t enter the longer string that the expression
evaluates to.