Scott Grissom
School of Computing & Info Systems
Grand Valley State University
picture

Lab: Pictures & Students

Preparation

Do the following before arriving at lab:

  • Read chapter 1
  • Know your GVSU login name and password
  • Bring your textbook to lab

Objectives

After completing this lab, you should be able to:

  • invoke object methods
  • inspect the state of an object
  • make simple changes to the source code and recompile

Exercises

Read Chapter 1 and perform each of the following exercises. Write your responses to any questions on this paper.

  1. Open the Picture project
  2. Exercise 1.10
  3. Exercise 1.12
  4. Exercise 1.13
  5. Exercise 1.15
  6. Define a new field of type Square called "sky" at the top of the class.
  7. Write a new method called "sunset". 1) Make the sun move down and out of the picture by invoking slowMoveVertical( ). 2) Cover the entire Canvas by instantiating the "sky" object as a large black square. 3) Change the color of the Window to yellow. 4) Redraw the existing Roof, Wal and Window by simply invoking makeVisible( ). You should not cut and paste code from the draw method. 5) Change the color of the Sun to white. 6) Move the white sun (i.e. the moon) up and into the picture by invoking slowMoveVertical( ) again.
  8. Write a method called "sunrise". Reverse the process in the sunset method to make the moon move down, the sky turn white, and the sun move up.
  9. Open the lab-classes project
  10. Exercises 1.17 - 1.22
  11. Modify the print ( ) method in the Student class to also print the number of credits. The new print statement will produce the following sample output: Fred Johnson (1234) credits: 12
  12. Exercise 1.23 - Use your name and three other students in the class
  13. Exercise 1.25 - Print the results listed in the terminal window. Cut and paste to Notepad and print (include your name).
Already done?

Choose from the following exercises:

  1. Create a crescent moon in the night picture. Carefully place a black circle over the moon to create the illusion.

Grading Criteria

This lab is worth a possible 10 points.

  • Turn in this printed Roster (with your name) from Exercise 1.25 (5 pts)
  • Sh0w the sunrise and sunset methods (5 pts)