Your goal (here and in any well written program) is to write the simplest possible code. For that, you have to decompose your work in sub-steps, and write a specific method for each sub-step.
If you observe carefully the picture to draw, it is constituted of four parts depicting a sort of V using a different color. A possible decomposition is to write a method in charge of drawing a V of the specified color from the current position. Its prototype can be:
[!java|c]void [/!]makeV([!java|c]Color [/!]c[!scala]: Color[/!])[!python] # parameter c is of type Color[/!]
The Color
data type naturally describes a particular
color. Your code should probably call makeV
with the following arguments
(a different color for each call):
In makeV()
, you should use the setBrushColor()
method (predefined in the buggle) to change the color of the buggle's brush,
as well as brushUp()
and brushDown()
to change the
brush position.
It may be wise to write the makeV()
so that it places directly
the buggle in position for the next V.
Your turn now. I'm sure you can imagine the other methods you need to keep your code simple and pleasant to read.
Complete the method run()
that should be called automatically (once).
[!java]the public
keyword means more or less that anybody can call this method, which is good because the PLM
infrastructure calls it directly.[/!]