This is a team assignment.
Many complicated movie scenes that you see involve lots of individually generated objects, all assembled together on one screen. A Pixar movie scene of a city (such as in The Incredibles) involves superimposing a number of buildings of different shapes and sizes. For this assignment, you will create a city landscape by drawing a number of buildings of varied sizes.
Create a directory named skyline1 (for Part 1) to store
your work, then copy into it the Canvas class from the course
directory. Create a class called Building
to represent a
building in a landscape. Specifically, it should have the following
methods:
Part 1: Due Friday
public void setHeight(int h)
h
)public void setWidth(int w)
w
)public void setColor(Color col)
col
)public void setHorizontalLocation(int
loc)
public void draw(Canvas canvas, int
canvasHeight)
Part 2: Due Monday
public void setHeightRandom(int maxHeight)
maxHeight
, inclusive)
public void setWidthRandom(int maxWidth)
maxWidth
, inclusive)public void setLocationRandom(int maxLoc)
maxLoc
,
inclusive)public void setColorRandom()
You should add on your own any private object variables that you need.
When you are ready to work on Part 2, create a new directory called skyline2. Copy all of your code into it, and begin from there.
Draw your building by doing what you can to make a rectangle look building-like. Add an antenna to the top of the building whose height is proportional to the rest of the building. Add vertical lines running down or across the building, or perhaps add windows. (With the techniques that we have discussed so far, though, your windows will need to scale with the building. We'll eventually talk about techniques which would allow you to have different numbers of windows to scale with the height of the building, but we're not there yet.)
Test your code as you go along. In other words, create
another class called Skyline
that creates and draws some
buildings. As you write methods in Building
, test them in
Skyline
. Submit your work for Part 1 by noon on Saturday,
and your work for Part 2 by 11:59 pm on Monday. When you are all done
with Part 2, test your code against the Skyline.java that I provide. It uses a few
techniques that we haven't talked about yet, but feel free to take a
look. If you have built your Building
class correctly,
this Skyline
program should generate an awesome skyline
for you to look at.
When finished with each part, use hsp to submit your skyline1 or skyline2 directory. Indicate in program comments the full names of both authors (you and your partner), as well as roughly what fraction of the time each team member spent "driving" at the keyboard. You should be working to give all team members approximately the same amount of time driving.
Good luck, and have fun! Remember that lab assistants are available in the evenings in CMC 306 to help out if you need it.