There are two classes that have information that changes because pieces move. I will cover the user interaction part in the next post.
For the COwner class;
bool COwner::Move(const int& fromL, const int& toL) |
Pre-Conditions: That fromL is greater than 0 and less than CBoard::NUM_PLACES. That toL is greater than 0 and less than CBoard::NUM_PLACES. And that fromL is NOT equal to toL. |
Get the element in Board's loc array that has the same value as fromL. Return false if this fails. Then assign toL to this element. Return true. |
And for the CGame class;
bool CGame::Move(const COwner::Player& tag, const int& fromLoc) |
Pre-Conditions: That tag is either COwner::playC or COwner::playU. That fromLoc is greater than 0 and less than CBoard::NUM_PLACES. And that fromLoc is NOT equal to emptyLoc. |
If tag was COwner::playC { If the Computer's Move routine succeeds { Change the owned array as appropriate. Assign fromLoc to emptyLoc. return true. } } else { If the User's Move routine succeeds { Change the owned array as appropriate. Assign fromLoc to emptyLoc. return true. } } If the program gets this far return false. |
No comments:
Post a Comment