예제 #1
0
 private void startSecondBuy() {
   try {
     ArrayList<Candidate> candidates = model.getSortedCandidates();
     writeMessage(10, candidates.size());
     out.writeByte(1);
     int numPlayers = model.getNumPlayers();
     for (Candidate candidate : candidates) { // This writes the top candidates
       out.writeByte(candidate.getCandidateNumber());
       int numVotes = candidate.getFirstVotes();
       int percentVotes = ((numVotes * 100) / numPlayers);
       out.writeInt(percentVotes);
     }
   } catch (IOException e) {
     removePlayer();
   }
 }
예제 #2
0
 private void startFirstVote() {
   try {
     ArrayList<Candidate> candidates = model.getCandidates();
     player.setRound("first");
     writeMessage(10, candidates.size());
     out.writeByte(0);
     int numPlayers = model.getNumPlayers();
     for (Candidate candidate : candidates) {
       out.writeByte(candidate.getCandidateNumber());
       int numVotes = candidate.getStrawVotes();
       int percentVotes = ((numVotes * 100) / numPlayers);
       out.writeInt(percentVotes);
     }
   } catch (IOException e) {
     removePlayer();
   }
 }