Last active
April 8, 2019 14:59
-
-
Save Maxcutex/0a23691216a2aea3f33e222262c18f03 to your computer and use it in GitHub Desktop.
Election Phase Two completed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.24; | |
contract Election { | |
// Model a Candidate | |
struct Candidate { | |
uint id; | |
string name; | |
uint voteCount; | |
} | |
// Read/write candidates | |
mapping(uint => Candidate) public candidates; | |
// Store Candidates Count | |
uint public candidatesCount; | |
constructor () public { | |
addCandidate("Candidate 1"); | |
addCandidate("Candidate 2"); | |
} | |
function addCandidate (string _name) private { | |
candidatesCount ++; | |
candidates[candidatesCount] = Candidate(candidatesCount, _name, 0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment