pragma solidity ^0.6.0; pragma experimental ABIEncoderV2; contract SimpleVoting { mapping (string => uint256) votesReceived; string[] public candidateList; mapping(address => bool) public checkVote; constructor(string[] memory candidateNames) public{ candidateList = candidateNames; } function voteForCandidate(string memory candidate) public { require(checkVote[msg.sender] != true, "voted"); checkVote[msg.sender] = true; votesReceived[candidate] += 1; } function totalVotesFor(string memory candidate) public view returns (uint256) { return votesReceived[candidate]; } function candidateCount() public view returns (uint256) { return candidateList.length; } }