Java OOP GUIDE / WORK HOUSE CLASS Topics
TASK –
PART 1 – NOOPDRAW Before
getting started with OOP, make sure you are comfortable with the NOOPDraw class that
provides easy graphics drawing functionality. There is a lesson
called “Static Graphics” in the Grade 11 course on this topic. Remember
that you need the NOOPDraw class in your current
Java project to use NOOPDraw functionality. TASK
– PART 2 – HOUSE CLASS INSTANCE VARIABLES Create
a House class that will store required information for House objects to be
drawn on the screen. The shape of a house will simply be a filled
rectangle and triangle (see image). A
house will also have a colour. The
house class will need the following instance variables.
TASK
– PART 3 – HOUSE CLASS CONSTRUCTORS Add
the following constructors to the House class: a)
Constructor #1 - It has an argument for every instance variable (datafield). b)
Constructor #2 - It gets info for all instance variables (datafields)
except colour. The colour is chosen randomly. TASK
– PART 4 – HOUSE CLASS METHODS In
this section, you will create a few simple methods.
b)
Method #2-Create the method getLeft()
that returns the x-coordinate of the left side of the house. c)
Method #3-Create the method getRight()
that returns the x-coordinate of the right side of the house. TASK
– PART 5 – HOUSE DRAW METHOD a)
In the main function of a class called Tester, create a few House
objects. Test each constructor and method. b)
Still in the main function, create a NOOPDraw
window. c)
In the House class, create a draw() method. It will draw the House object using NOOPDraw methods. d)
In the main function, use the draw() method on each
house to draw them. |
|