In class we saw how to compose objects to create a BoxCar class. Now we’re going to create another composite shape: Tree.
Rx: <25 min Av: 25-50 min Sd: 50-75 min DNF: 75+ min
Tree
class with:
top
& a Rectangle for the trunk
x
, y
, width
, & height
x
, y
, width
, height
, topColor
, trunkColor
topColor
& trunkColor
setBounds
method that:
x
, y
, width
, & height
x, y
and extends to width
& height
paint
method that takes a Graphics
parameter and calls the draw methods of the 2 fieldssetBounds
to verify that it works correctly for any size tree.