コード例 #1
0
Dialog::Dialog( int type ){
    initDialog();   
    switch( type ){
        case ASK_COAL_SURVEY:
            coalSurvey();
            break;
        case GAME_STATS:
            gameStats();
            break;
        default:
            std::stringstream msg;
            msg <<"Can't open Dialog type " << type << " without additional parameters.";
            throw std::runtime_error(msg.str());
    }
}
コード例 #2
0
ファイル: gameRun.c プロジェクト: ChrisHoder/Projects
void  gameRun() {
  user.wins = 0;
  user.loss = 0;
  user.ties = 0;
  user.total = 0;
  printStart();
  int i=0;

  while (i == 0){
    char comp;
    printf("Enter p, r, or s: ");
    char strchoice[10];
    fgets(strchoice,sizeof(strchoice),stdin);

/* decides action based on input. Either starts game, help, exit or wrong input */
    switch(strchoice[0]) {

      case 'r':
      case 'p':
      case 's':
	/* gets the computer's choice in the game */
	comp = computerChoice();
	/* this function will compare the two choices to determine winner */
	srand(time(NULL));
	playGame(comp,strchoice[0]);
	break;

     case 'h':
      helpFunc();
      break;

    case 'g':
     gameStats();
     break;
  
    case 'e':
      i=1;
      break;

    default:
      printf("\n\nPlease type a correct input character");
      helpFunc();
    }
  }

}