In this assignment you’ll create an applet that randomly generates a city skyline at night.
The heights and widths of each building must be selected at random.
And, you’ll need to put windows onto the faces of your buildings -- the number and position of all the windows will be
random. You’ll need to draw a nighttime sky as a background. The sky has a random number of stars in it, and they’re at
random locations. Your city does not need to look like the city shown above. Be creative and have fun!
Your program must contain two classes: (1) The public
class, called Skyline
,
that contains the setup and initialization code, the paint
method, etc., and (2) An ordinary
(non-public) class, called Building
, that describes and draws a single building.
init()
method that sets the background color.
paint()
method that does all the painting that needs to be done,
exclusive of the painting that’s handled by the Building
class methods.
Building()
, that initializes the current building’s
width and height. You will have to decide if your constructor takes any arguments.
draw()
method that displays the current building.
You’ll need to decide what arugments draw()
needs and whether or not it returns a value or is void.
You may put both classes into the same file, Skyline.java
, if you wish.
Or you may put each class into a separate file, Skyline.java
and Building.java
.
The choice is yours, but make sure you will upload both class
files to your website!
You will need a web page to display your applet. Your homepage should have a link to the web page for this assignment.
Submit the URL of your applet along with your Java code (the .java
file(s)) in an email message
to mrsimon@lycos.com.