Random A

Remember to include System.Random to make these exercises work.

  1. Print a random integer in the range [1,10].

  2. Print a random Double in the range [100,200].

  3. Make a circle of radius 2 centered at the origin with a random color from this list:

     somecolors = [red, orange, yellow, green, blue, purple]
    
  4. Create a function that takes in a StdGen and produces a random color from the somecolors list (above).

  5. Create a CS record (data) that holds a pt :: Point, a cx :: Color, and a gen :: StdGen.

  6. Given a CS record, draw a solid radius 1.0 circle of that color at the point in the record.

  7. Make a drawing that selects new a random coordinate and color every time the person hits a key. Except hitting “C” should just randomly change the color.

Last modified December 14, 2023: Moved location of randomness pages. (603756c)