//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f. pragma solidity ^0.4.18; contract ElectionC { struct Candidate { uint8 votes; string name; } address contractCreator; Candidate[] candidates; mapping (address => uint) votingRecord; constructor() public { candidates.push(Candidate(0, "JP")); candidates.push(Candidate(0, "Binsu")); contractCreator = msg.sender; votingRecord[msg.sender] = 0; } function setVote(uint _index) public { require(votingRecord[msg.sender] != 1); votingRecord[msg.sender] = 1; candidates[_index].votes++; } function getVotes(uint _index) public constant returns (uint) { return candidates[_index].votes; } function addCandidate(string _name) public { candidates.push(Candidate(0, _name)); } }
0.4.25