This course has already ended.
You cannot submit this assignment

You need to sign in and enrol to submit exercises.

Assignment 22

This assignment is entirely voluntary, just like all the other training/challenge assignments in gray-bordered boxes like this are. You’ll run into them here and there in upcoming chapters. A+ nominally awards you a single point for each bonus assignment completed, but that doesn’t count towards your grade; only A/B/C points do.

1 point

Let’s make an animation.

Define some variables as follows.

val sizeOfLamp = 250
val redLamp    = circle(sizeOfLamp, Red)
val yellowLamp = circle(sizeOfLamp, Yellow)
val greenLamp  = circle(sizeOfLamp, Green)
val trafficLights = Buffer(redLamp, yellowLamp, greenLamp)

Package o1 provides an effectful function animate that displays a number of images one after another, thus turning them into an animation. The function expects two parameters:

  • a bufferful of pictures; and

  • a positive number (Double), that determines the speed of the animation. A larger number results in a faster animation.

Experiment with animate. In the field below, enter a command that animates the contents of the buffer that the variable trafficLights refers to. Use the speed 1.0. If you want, go ahead and come up with other things to animate.

Posting submission...

Earned points

0 / 1

Exercise info

Assignment category
Optional
Your submissions
0
Deadline
Wednesday, 13 September 2023, 18:00
Late submission deadline
Monday, 15 April 2024, 12:00 (-100%)
Group size
1-2
Total number of submitters
593