Sunday, February 3, 2013

Xmover and display()

Xmover:

 case DOWN:
      if((row == console.getRows()-2) && (col == console.getCols()-1)){
          console.alarm();
      }
      else if(row < console.getRows()-1){
        row++;
      }
      else{
        console.alarm();
      }
      break;
 case RIGHT:
      if( (col == console.getCols()-2) && (row == console.getRows()-1)){
            console.alarm();
        }
      else if(col < console.getCols()-1){
        col++;
      }
      else{
        console.alarm();
      }
      break;
    case ESCAPE:
      done = true;
      break;
    }
 

display():

void Console::display(const char* str, int row, int col, int fieldLen){
    console.setPos(row, col);
    for(int i = 0;(fieldLen == 0)?(str[i]!=0):((str[i]!=0)?(str[i]!=0 && i<fieldLen):(i<fieldLen));(str[i]!=0)?(putChar(str[i]),i++):(putChar(' '),i++));
}

No comments:

Post a Comment