CyberSlug Rules!

Beginner Programming CMPS060

Prof. Paulo Franca

Home

Syllabus

Login

Objects

Download

Staff only

#include "franca.h"
Robot Tracer; // c4search.cpp
void go()
{
if (Tracer.seenowall())// Check for a wall
{
// do this only if next square is clear:
Tracer.mark(4); // mark in light blue
Tracer.step(); // step ahead
Tracer.say("OK"); // say: OK!
}
}
void mainprog()
{
int where;
do
{
where=ask("Which way should I go?");
Tracer.face(where);
go();
}
while (yesno("Shall we go on?"));
}