| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 | #include "olok.h"Olok::Olok(){    clear();}void Olok::clear(){    // clear the grid to be rebuilt as empty    grid.clear();    // make 11 boxes for each colored row (not the white ones)    for(int j = 0; j<white1; j++)    {          RowColor empty;        grid.push_back(empty);          for (int i = 0; i<CHECKBOXES; i++)        {            grid[j].row.push_back(false);        }    }    // clear penalty count     penaltyCount = 0;}// get checked off box count for a specific colorint Olok::getXCount(int color){   return grid[color].xCount;}// add checked off box to a specific index on a colorvoid Olok::addX(int color, int index){    grid[color].row[index] = true;    grid[color].lastIndex = index;}// check for last value of indexint Olok::getLastIndex(int color){    return grid[color].lastIndex;}// add any Xs from input Olok into this Olokvoid Olok::addOlok(Olok o){    // find changes in currentTurnOlok and transfer to cumulativeOlok    for(int j = 0;j <o.grid.size();j++)    {        // loop over all Xs in a color        for(int k = 0;k <o.grid[j].row.size();k++)        {            // check for true values in currentTurnOlok's grid            if(true ==o.grid[j].row[k])            {                // transfer true values from currentTurnOlok's grid to cumulativeOlok's grid                grid[j].row[k] = true;            }        }    }    // player selects to add penalty, increase the penalty count    penaltyCount += o.penaltyCount;}std::string Olok::toString(void) {    std::string output;    // check each row on the grid on the scoresheet    for(int j = 0; j < grid.size(); j++)    {        // check each box on the row and then store output        for(int k = 0; k < grid[j].row.size();k++)        {            // look at checkbox value, add it to output            output.push_back(grid[j].row[k] ? 'T' : 'F');        }    }    // add penalty count to output    output.push_back(penaltyCount + '0');    return output;}
 |