//introducing mapping (any person can vote only once) pragma solidity ^0.4.17; contract Vote { string canditate1_name; string canditate2_name; uint256 Count_canditate1_vote; uint256 Count_canditate2_vote; address voter; mapping (address => bool) public voters; function Vote (string _canditate1Name, string _candidate2_name){ canditate1_name=_canditate1Name; canditate2_name=_candidate2_name; } function getCountofCandidate1() public view returns(uint256){ return Count_canditate1_vote; } function getCountofCandidate2() public view returns(uint256){ return Count_canditate2_vote; } function SetVote(uint256 _can){ require(voters[msg.sender]==false); if(_can==1){ Count_canditate1_vote=Count_canditate1_vote+1; } else if(_can==2){ Count_canditate2_vote=Count_canditate2_vote+1; } voters[msg.sender]=true; } function getWinner() public view returns(string) { if(Count_canditate1_vote>Count_canditate2_vote){ return canditate1_name; } else { return canditate2_name; } } }