next up previous
Next: What to turn in Up: Part Two Previous: Part Two

Using objects as parameters

1.
Start with a clean copy of the Snowperson assignment. You can use my solutions if you want (they are on the General Server), or you can use your solution. If you use your solution, you might want to take a minute to review it, make sure you remember how it works, and clean it up a little.
2.
Modify the Snowperson code so that every method that receives a bounding box as an argument gets a single Rectangle object instead of four integers. For example, the declaration of paintSnowperson would look like

	public void paintSnowperson (Graphics g, Rectangle bb)

3.
Along with your modified code, turn in a paragraph that compares the two versions, discussing things like readability, debuggability, code length, encapsulation and abstraction.

In the Java library, they had the option of using Rectangles to pass parameters to methods like drawRect and drawOval, but they chose to pass four integers instead. In fact, there are only a couple of methods in the whole Java library that use Rectangles at all. What do you think of this decision? Would you prefer a version of drawOval that takes a single Rectangle as an argument? What if you could have both?


next up previous
Next: What to turn in Up: Part Two Previous: Part Two
Allen B. Downey
3/11/1998