166 Review QuestionsΒΆ

Write a function called getColor(name) that takes the English name of a color as input, and returns an RGB triple for that color. Make it work for, at least, red, green, blue, white, and black.

You could use it to write code like this:

color sky = getColor("blue");
color apple = getColor("red");
color snow = getColor("white");

Write a program that draws a green-filled circle in the center of the screen. When the mouse hovers over the circle, it changes to red-filled. When the mouse moves off the circle, it changes back to green.


Write a program that prints the numbers from 100 down to 1 on the screen, and then prints “Blast off!”:

100
99
98
...
3
2
1
Blast off!!

Do this first using a while-loop, and then using a for-loop.


Write a class called Point that represents a 2-dimensional (x, y) point. It should work with code like this:

Point a = new Point(200, 300);
Point b = new Point(a);
Point origin = new Point();

a.display();  // prints "(200.0, 300.0)" on the console
b.display();  // prints "(200.0, 300.0)" on the console
origin.display();  // prints "(0.0, 0.0)" on the console