Homework 1 

(10 points)

 

Note: if you work from home, follow the instructions on the resource page to install Eclipse and the UWLibrary. Here is a description of the content of the library that you might find useful.

You are starting to plan your Halloween party. I know that there is still plenty of time. This year you have decided that you will not be be doing it at the last minute. To decorate your place, you want to put on the walls Halloween pictures. "Why not creating these pictures with a a Java program?" you think. You are filled with excitement and start thinking about what you can do.

Overview

In this project, you will complete several classes to draw a picture in a graphics window. The purpose of this assignment is to give you experience writing classes in Java and using Eclipse.

To do

Download the four files Candle.java, HalloweenScene.java, Pumpkin.java and Spider.java and include them in an Eclipse project (as we did in class). Open all of the files. To run the program, select the tab corresponding to the HalloweenScene class and click the "Run" button. You should get a window with a rectangle in the lower left area (the rectangle is the beginning of the drawing of a candle). Read through the code of HalloweenScene and Candle. You will see that when HalloweenScene is instantiated, a graphics window is created. Then a Candle object is created. According to the draw method of Candle, it appears as a rectangle. Make sure that you understand how this is happening within the code.

None of the classes given to you are complete. Your assignment is to complete the four classes so that an instance of HalloweenScene appears as a picture containing different Halloween elements. Here is a list of the requirements of the assignment :

If you want to create your own colors, use the Color constructor. It reads Color(r,g,b) where r,g and b are integers between 0 and 255. The color is a mixture of red, green and blue as specified by r, g and b. For example

Color myColor = new Color(100,150,210); // a blueish color

Good luck!

Here is a possible picture (shown with only three types of elements. You have to put in a fourth one as well).

 

Your program has to be your own.