Java OOP GUIDE / WORK LINE CLASS 2 Topics
TASK –
PART 1 – SETUP – LINE CLASS & POINT CLASS Start by
copying the following Line & Point classes to your IDE. Notice that the Line class is already using
aggregation.
TASK –
PART 2 – USE ENCAPSULATION ON THE POINT CLASS Use
encapsulation on the Point class by:
TASK –
PART 3 – USE ENCAPSULATION ON THE LINE CLASS Use
encapsulation on the Line class by:
TASK –
PART 4 – TOSTRING METHODS For
convenience, we will add to String methods to both Line and Point
TASK –
PART 5 – TESTING THE LINE CLASS Do the
following: a)
Create
a Line object that has points (4,2) and (9,1). b)
Output
the Line object to screen. c)
Write
the statement needed to output x1 to screen.
(It should be 4.) d)
Write
the statement needed to change y2 to 13 and then output the line to screen. e)
Output
the first point of the line to screen. f)
Change
p1 so that it is now at (2,3). Output
the line to screen. |
||
|