boat1
,
instantiated/constructed the Boat object passing specific values
for the name of the Boat and where it is located in the display window
to the Boat constructor method,
and used the Boat object by calling its draw
method
and its toString
method.boat2
and boat3
. You may either add a separate line for each
declaration and mimic the style we used to declare boat1
, or you may declare all three
Boat objects with one line of code. Don't forget
the semicolon on the end of every line.boat1
, add lines of Java code to instantiate
boat2
and
boat3
, using different values for the overs and downs and the names of the boats. Also, add lines
of Java code to use System.out.println and the toString
method of these
Boats to display information about them in the Java Console.paintComponent
method of the MUPanel.java file we have asked
draw
method right after the comment "// port holes"
add lines of Java code to make three port holes. For each port hole set
the color for the Graphics object called g
to Color.YELLOW, use the
fillOval method of g
to make a solid yellow circle, set the g
color to
Color.BLACK, and finally use the drawOval method to make a hollow black
oval outlining the yellow oval.anchorX
and anchorY
points of the
Boat. In other words:Do stuff like this: | But NOT like this: |
---|---|
g.drawOval(anchorX – 15, anchorY + 30, 20, 20); |
g.drawOval(85, 215, 20, 20); |
draw
method right after the comment "// name on the
sail" add lines of Java code to set the color to Color.BLACK and use
the drawString
method of the g
object to display the boatName property of the Boat
on the sail. Hint: you cannot use a string literal surrounded by "" characters in the g.drawString
method call to do this.draw
method right after the comment "// lines
steadying the mast" add code to set the color to Color.YELLOW and use
the drawLine
method of the g
object to draw lines from the front and
back of the Boat to the top of the mast. Recompile, run, test, fix, etc.draw
method of your Boat class correctly, your fourth boat will
have portholes in the proper place, lines from the mast to the boat deck, etc. If you used
numbers instead of drawing things relative to the (anchorX, anchorY) point of the Boat, then your
new boat won't have portholes. Ask your instructor for help if your fourth boat isn't displayed
correctly.