Java OOP GUIDE / WORK LINE CLASS Topics
TASK –
PART 1 – BASIC LINE CLASS
(2,5) to (5,5) [length=3] TASK –
PART 2 – ARRAYLIST In main of a
Tester class, create an ArrayList with at least
five different Line objects in it.
Output the content of the ArrayList to
screen. TASK –
PART 3 – IMPLEMENT COMPARABLE We now want
to sort the Line objects in the ArrayList by
length. The easiest way to do this is
to make the Line class implement the Comparable interface. Make it so. TASK –
PART 4 – SORTING Now that Line
objects can be compared, we can use Collections.sort()
to sort lines. Sort the ArrayList and output it to screen to confirm that the
sorting is working correctly. |
|