Beispiel #1
0
 public void insert(Player player) {
   switch (player.getType()) {
     case FOOTBALL:
       {
         insertPlayer(player);
         insertFootBaller((FootBaller) player);
         break;
       }
     case CRICKET:
       {
         insertPlayer(player);
         insertCricketer((Cricketer) player);
         break;
       }
     case BOWLING:
       {
         insertPlayer(player);
         insertCricketer((Cricketer) player);
         insertBowler((Bowler) player);
         break;
       }
     default:
       throw new AppRuntimeException("unknown type");
   }
 }
Beispiel #2
0
 private void insertPlayer(Player player) {
   try {
     String stmtInsert = String.format(STATEMENT_INSERT, "players", "?,?,?");
     PreparedStatement stmt = prepareStatement(stmtInsert);
     stmt.setLong(1, player.getId());
     stmt.setString(2, player.getName());
     stmt.setString(3, player.getType().toString());
     stmt.executeUpdate();
   } catch (SQLException e) {
     throw new AppRuntimeException(e);
   }
 }
Beispiel #3
0
 private void updatePlayer(Player player) {
   try {
     String stmtUpdate = String.format(STATEMENT_UPDATE, "players", "name=?,type=?");
     PreparedStatement stmt = prepareStatement(stmtUpdate);
     stmt.setString(1, player.getName());
     stmt.setString(2, player.getType().toString());
     stmt.setLong(3, player.getId());
     stmt.executeUpdate();
   } catch (SQLException e) {
     throw new AppRuntimeException(e);
   }
 }
 /**
  * フェイズごとの処理
  *
  * @param info ポーカー情報。
  */
 private void onPhase(final PokerInfo info) {
   final Player activePlayer = info.getActivePlayer();
   switch (activePlayer.getType()) {
     case HUMAN:
       info.notifyObservers(new AnnounceParam(activePlayer, AnnounceFlag.HAND_TALK));
       break;
     default:
       // 空席は無視
       next(info);
       break;
   }
 }
Beispiel #5
0
 public void delete(Player player) {
   deleteRow(player, "players");
   switch (player.getType()) {
     case FOOTBALL:
       deleteRow(player, "footballers");
       break;
     case CRICKET:
       deleteRow(player, "cricketers");
       break;
     case BOWLING:
       deleteRow(player, "cricketers");
       deleteRow(player, "bowlers");
       break;
     default:
       throw new AppRuntimeException("unknown type");
   }
 }
Beispiel #6
0
 public void update(Player player) {
   switch (player.getType()) {
     case FOOTBALL:
       updatePlayer(player);
       updateFootBaller((FootBaller) player);
       break;
     case CRICKET:
       updatePlayer(player);
       updateCricketer((Cricketer) player);
       break;
     case BOWLING:
       updatePlayer(player);
       updateCricketer((Cricketer) player);
       updateBowler((Bowler) player);
       break;
     default:
       throw new AppRuntimeException("unknown type");
   }
 }