pragma solidity ^0.5.2; contract Voters { mapping (uint256 => bool) voteDecision; mapping(uint256 => mapping (address => bool)) HaveVoted; mapping (uint256 => uint256) voteTrue; address owner; uint256[] vote; uint256 i = 0; uint256 voted = 0; mapping (address => bool) registeredVoters; constructor ( ) public { owner = msg.sender; vote.push(0); } function setNewVote () public { uint256 h = 1; vote.push(h); i++; } modifier checkNewVoter () { require(registeredVoters[msg.sender] != true); _; } function addVoter() public { require(msg.sender != address(0)); registeredVoters[msg.sender] = true; } function getRegisteredVoters(address x) public view returns (bool) { return registeredVoters[x]; } function voting (uint256 x, bool answer ) public returns(uint256) { require(x <= vote.length); if (answer = true) { voteTrue[x] = i++; } voted++; if(voted >= 4) { if (voteTrue[x] >= 2) { voteDecision[x] = true; } i = 0; voted = 0; } return voted; } function getVoteDecisions (uint256 x) public view returns (bool) { return voteDecision[x]; } }
0.5.2