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).
To reach that goal, you had to write a method isFacingTrail that will be called automatically by the buggle on each step. Your method should return [!python]True[/!][!java|scala]true[/!] if facing a green cell, or [!python]False[/!][!java|scala]false[/!] if not. Of course, if we are facing a wall, it should return false without bumping into it. You should make sure that this method has no side effect, i.e. that it does not change the state of the calling buggle nor of its world.
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).