Il tuo buggle è felicissimo! Ha appena trovato una bavosa traccia verde sicuramente lasciata da una grossa e deliziosa lumaca. Il buggle è certo che alla sua fine si intratterrà con un con questa appetitosa lumaca (rappresentata con un baggle).
Per raggiungere l'obbiettivo dovrai scrivere il metodo booleano isFacingTrail (Ndt davantiTraccia) che determinerà di fronte abbiamo una cella verde oppure no. Ovviamente se ad esempio sarete davanti ad un muro esso dovrà ritornale false senza andarci a sbattere. Dovrete assicurarvi che questo metodo non avrà effetti collaterali e cioé che non cambi il buggle che lo sta chiamando o il mondo che lo circonda.
Your tool to that end is the getGroundColor()
that returns the
color of the current cell. Just go to the cell you want to test and run that
function. [!java]You cannot test whether this color is equal to
Color.green
with an ==
sign but instead you have
to write something like
getGroundColor().equals(Color.green)
. This is because green is
an object in Java, and .equals()
is the way to go to
test equality between Java objects.[/!] [!python|scala|c]So you just have to
test whether the returned color is equal to the value
[!scala|python]Color.green[/!][!c]GREEN[/!]
, that represents
the green color.[/!]
Scrivi il metodo isFacingTrail()
(che sarà chiamato
automaticamente dal buggle).