Java OOP GUIDE / WORK LINE CLASS Topics
TASK –
PART 1 – SETUP – LINE CLASS Start by
copying this Line class to your IDE.
TASK –
PART 2 – SETUP – POINT CLASS Instead of
having four doubles for instance variables, we can have two Point
objects. However, to do this, we need
to have a Point class to work with. Copy the
following Point class to your IDE.
TASK –
PART 3 – USING AGREGATION Aggregation
is simply the concept of using objects as instance variables for other
objects. Instead of having four double
data fields, we will switch the Line class’ data fields to be two
points.
TASK –
PART 4 – TESTING THE LINE CLASS Do the
following: a)
Create
a Line object. b)
Output
the value of the first point’s x-coordinate to screen. c)
Output
the value of the second point’s y-coordinate to screen. d)
Set
the first point’s y-coordinate to 12. |
||||
|