2016-07-29 8 views

답변

0

안개 속에서 계약을 맺고 winningProposal() 기능을 실행하십시오. 이것은 모든 이전 표를 고려하여이기는 제안을 계산합니다. 안개가 함수 이름을 소독하라고/이름을 변경

/// @dev Computes the winning proposal taking all 
/// previous votes into account. 
function winningProposal() constant 
     returns (uint winningProposal) 
{ 
    uint winningVoteCount = 0; 
    for (uint p = 0; p < proposals.length; p++) { 
     if (proposals[p].voteCount > winningVoteCount) { 
      winningVoteCount = proposals[p].voteCount; 
      winningProposal = p; 
     } 
    } 
} 

주, 그것은 Winning Proposal 또는 winning proposal 이름이 될 수 있습니다. 인수없이 호출 할 수 있습니다.

가장 많은 표를 얻은 제안서의 ID를 반환합니다. proposals 구조체보기 :

// This is a type for a single proposal. 
struct Proposal 
{ 
    bytes32 name; // short name (up to 32 bytes) 
    uint voteCount; // number of accumulated votes 
}