title: Switch or something else
body: <p>I am making some game application about Janitors. It's in the early stage, and so far I am proud on it, however as time passes by my code is becoming really messy, so I decided to come over and ask for any help to solve/remake/implement this code in another way without so many cases. I was thinking about implementing some design pattern, however I am not sure which one. Any help is appreciated.</p>
  
  <pre><code>bool JanitorApp::key(unsigned char key)
  {
  if (MainApp::key(key)) return true;
  
  switch(key) {
  case 'Q': case 'q':
      current[0] = NULL;
      status[0] = "Stationary";
      return true;
  case 'W': case 'w':
      current[0] = &amp;cleans[0];
      status[0] = "Cleaning";
      return true;
  case 'E': case 'e':
      current[0] = &amp;eats[0];
      status[0] = "Eating";
      return true;
  case 'R': case 'r':
      current[0] = &amp;guards[0];
      status[0] = "Guarding";
      return true;
  
  case 'A': case 'a':
      current[1] = NULL;
      status[1] = "Stationary";
      return true;
  case 'S': case 's':
      current[1] = &amp;cleans[1];
      status[1] = "Cleaning";
      return true;
  case 'D': case 'd':
      current[1] = &amp;eats[1];
      status[1] = "Eating";
      return true;
  case 'F': case 'f':
      current[1] = &amp;guards[1];
      status[1] = "Guarding";
      return true;
  
        case 'Z': case 'z':
      current[2] = NULL;
      status[2] = "Stationary";
      return true;
  case 'X': case 'x':
      current[2] = &amp;cleans[2];
      status[2] = "Cleaning";
      return true;
  case 'C': case 'c':
      current[2] = &amp;eats[2];
      status[2] = "Eating";
      return true;
  case 'V': case 'v':
      current[2] = &amp;guards[2];
      status[2] = "Guarding";
      return true;
  }
  
  return false;}
  </code></pre>