# soluciones_ch01.pdf

View again

All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Information Report
Category:

## Documents

Published:

Views: 15 | Pages: 3

Share
Related documents
Description
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 ã
Transcript
Exercise 1.9The 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 objects 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 the object was created. Exercise 1.20  It shows the number of students in the labclass which is zero. Exercise 1.27 0 int hello String 101 int -1 int true boolean 33 String 3.1415 double Exercise 1.28 First you would have to decide which type the field should have. String would be a good type to hold a name, so we add the following line to the source file of Circle: private String name; The above line could be placed after this line in the source code of the Circle class: private boolean isVisible;  Exercise 1.29 public void send(String msg) Exercise 1.30 public int average(int firstNumber, int secondNumber) Exercise 1.31 The book is an object. The class could be Book  . Exercise 1.32 Yes, an object can belong to several classes. One of the more famous examples are the platypus, which is both a mammal and egg-laying.
Recommended

71 pages

17 pages

39 pages

27 pages

28 pages

52 pages

75 pages

37 pages

13 pages

30 pages

71 pages

5 pages

16 pages

26 pages

31 pages

View more...