Skip to content

Instantly share code, notes, and snippets.

@Maxcutex
Last active April 8, 2019 14:59
Show Gist options
  • Save Maxcutex/0a23691216a2aea3f33e222262c18f03 to your computer and use it in GitHub Desktop.
Save Maxcutex/0a23691216a2aea3f33e222262c18f03 to your computer and use it in GitHub Desktop.
Election Phase Two completed
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