View Single Post
Old Nov 30th, 2006, 10:24 PM   #27
aznballerlee
Hobbyist Programmer
 
Join Date: Nov 2006
Posts: 111
Rep Power: 2 aznballerlee is on a distinguished road
Quote:
In the robot step method, you need to call the energySourceAt accessor for the valley object for this robot, to determine if there is an energy source at the current location.
You are right, I was thinking about that too.
if (energySourceAt(r,c))
       m_energy = FULL_ENERGY;

Quote:
You also need to write the energySourceAt accessor
Here's my problem, it doesn't compile:
bool energySourceAt(int r, int c) const
//      If there is an energy source at coordinates (r,c), return true;
//      otherwise, return false.
{
	if (EnergySource(r,c))
		return true;
	else
		return false;
}

Quote:
The Valley class has an array of energy sources - you need to look through that array to see if there is one at the current coordinates.
if (m_sources[MAXSOURCES] =EnergySource(m_row, m_col))
EDIT: Ahh, this doesn't work.

Last edited by aznballerlee; Nov 30th, 2006 at 10:46 PM.
aznballerlee is offline   Reply With Quote