View Single Post
Old Dec 1st, 2006, 11:02 PM   #55
aznballerlee
Hobbyist Programmer
 
Join Date: Nov 2006
Posts: 111
Rep Power: 2 aznballerlee is on a distinguished road
I'm onto my next task, and I'm stuck. This is in the Robot::step function.
Quote:
// If at this spot there's another robot whose energy level is 0,
// then if we have at least SHARE_THRESHHOLD units of energy,
// transfer SHARE_AMOUNT units to that other robot. (If there
// are two or more dead robots here, we donate to only one.)
// Return true, indicating the robot attempted to move.
     for (int h=0; h < m_nrobots; h++)
    {
        if ((m_robots[h] -> row() == this -> row() )
            && (m_robots[h] ->  col() == this -> col())
            && (m_robots[h] != this)
            && ((m_robots[h] -> energy() == 0)))
            return true;
        {
            m_energy -= SHARE_AMOUNT;
            m_robots[h] -> energy() = SHARE_AMOUNT;
        }
    }

I have two errors which you can help me figure how to fix.

Quote:
1. left of '->energy' must point to class/struct/union/generic type
Currrently, the m_robots[h] are of type int. I don't know how to turn them into classes.

Quote:
2. m_nrobots and m_robots are undeclared identifiers.
I looked at the classes, and that's right. Those are part of the Valley class. There aren't anything variables (not that i can find) in Robot that can tell me the robot size though!
aznballerlee is offline   Reply With Quote