CyberSlug Rules!

Beginner Programming CMPS060

Prof. Paulo Franca

Home

Syllabus

Login

Objects

Download

Staff only

Mark in black or green

suppose you want Tracer to mark a square in black or green depending upon whether she sees a wall in it or not:

 

int black=7,green=2;

if (Tracer.seewall()) // check for a wall ahead. If so:

{

Tracer.mark(black); // then... mark in black

}

else

{

Tracer.mark(green); // else... mark in green

}