View Single Post
Old Dec 1st, 2006, 11:37 PM   #56
aznballerlee
Hobbyist Programmer
 
Join Date: Nov 2006
Posts: 111
Rep Power: 2 aznballerlee is on a distinguished road
Not meant to overwhelm you, but I worked on the remaining functions, and I'll pose my problems here. (I think most of them revolve aroudn the same idea, so we can work on them simultaneously)

1. Robot:step (remaining part)
This problem is listed in my previous post(s).

2. Valley::display() (Part 1)
        
// TODO:  indicate each robot's position
// for each robot in the valley,
//   set the appropriate element of the grid to the first character
//          of the robot's name.
    for (int b = 0; b < m_nrobots; b++)
    {
        grid[r][c] = 'name()';   // TODO: Fix name() so only first char of name
I have trouble setting name to only first char. Also, not sure if my steps are right.

3. Valley::display() (Part 2)
        
        // TODO:  Write robot energy info
        // for each robot in the valley,
        //   write the robot's name and remaining energy level.

        cout << name() << endl;
        cout << energy() << endl;
Also, not sure I did this part right as well.

4. Valley::step()
Robot:step () made the single robot move. Valley::step() makes ALL the robots move one step.

bool Valley::step()
{
    //      TODO: implement step
    //      Have each robot in the valley step.  If any of them attempted to move,
    //      return true.  If none of them did, they're all dead, so return false.


for (int p = 0; p < m_nrobots; p++)
{
    if (m_robots[p].step)
        return true;
}
 return false;
}
Once again, the main issue is that the one in Problem 1. The left side is not a pointer to class or something . Blah.
aznballerlee is offline   Reply With Quote