Copying and Pasting cs Code

In cs, like in almost any computer programming language, reading data from a file can be tricky. You add extra lines of code to tell the computer what to do. Sometimes you can copy and paste these lines from other peoples’ code.

For example, you can follow the pattern in this listing:

  public void GameOver(GCPlayer winner, GameOverType gameOverType) {
   AddGame();
   switch (gameOverType) {
    case GameOverType.CHECKMATE:
     if (winner == p2) {
      winnerText.text = "CHECKMATE: BLACK wins";
      AddScore(PLAYER_BLACK);
     } else if (winner == p1) {
      winnerText.text = "CHECKMATE: WHITE wins";
      AddScore(PLAYER_WHITE);
     }
    break;
    case GameOverType.STALEMATE:
     winnerText.text = "STALEMATE: It's a tie";
    break;
    case GameOverType.OUT_OF_TIME:
     if (winner == p1) {
      winnerText.text = "OUT OF TIME: WHITE wins";
      AddScore(PLAYER_WHITE);
     } else if (winner == p2) {
      winnerText.text = "OUT OF TIME: BLACK wins";
      AddScore(PLAYER_BLACK);
     }
     break;
   }
   continueButton.SetActive(true);
  }