This GitLab instance reached the end of its service life. It won't be possible to create new users or projects.

Please read the deprecation notice for more information concerning the deprecation timeline

Visit migration.git.tu-berlin.de (internal network only) to import your old projects to the new GitLab platform 📥

SimpleVoting.sol 351 Bytes
Newer Older
Robert Muth committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
pragma solidity >=0.4.21 <0.6.0;

contract SimpleVoting {
	uint public maxOption;
	mapping(uint => uint) public votes;

	constructor(uint _maxOption) public {
		assert(_maxOption >= 0);
		maxOption = _maxOption;
	}

	function vote(uint _option) public {
		require(_option <= maxOption);
		assert(votes[_option] < 2**256 - 1);

		votes[_option]++;
	}
}