Exercise 1.9
The main building:
- Create a new Square object
- Invoke its method makeVisible()
- Make the square bigger by invoking the method changeSize(newSize)
(100 is a good size)
- Move the square down by invoking the method moveVertical(distance)
(again 80 is a good value)
The window:
- Create a new Square object.
- Invoke its method makeVisible()
- Change its color by invoking changeColor()
- write "black" in the popupwindow
- Move the square down by invoking the method moveVertical(distance) (100 is a good value)
- Move it to the right by invoking moveRight()
The roof:
- Create a new triangle object.
- Invoke its method makeVisible()
- Change its size with changeSize(newHeight, newWidth) (50,140)
- moveVertical(70)
- moveHoizontal(60)
The Sun:
- Create new Circle object.
- Invoke its method makeVisible()
- Change its color by invoking changeColor()
(write "yellow" in the popupwindow) Optionally change its size with changeSize(60)
- Move it to the right by invoking moveHorizontal(180)
|
Exercise 1.11
- It uses the objects of the classes Circle, Square and Triangle.
- It then moves these obejcts to the right places and
changes the sizes and colors of the obejcts. Essentially calling
the same methods as used in exercise 1.9
|
Exercise 1.15
After the line sun.makeVisible() insert the following:
- sun.slowMoveVertical(250);
- Compile the Picture class (Press compile in the editor window)
- Create instance of class Picture and invoke its draw() method.
|
Exercise 1.16
Remove the line (if added in the previous exercise): slowMoveVertical(250);
Right below the last } after the draw() method, add the sunset()
method :
/**
* Animates the sunset.
*/
public void sunset() {
sun.slowMoveVertical(250);
}
Compile! And run it.
|
Exercise 1.18
When calling the method getName(), the name of the student is
displayed in a popup window. The name displayed is the one typed
in when creating the object.
|
Exercise 1.20
It shows the number of students in the labclass which is zero.
|