Skip to main content
added 3170 characters in body
Source Link

//SPDX-Licence-Identifier: GNU AGPL pragma solidity >= 0.5.0 < 0.9.0;

contract Election{ struct Candidate{ string name; uint numVotes; } struct Voter{ string name; bool authorised; uint whom; bool voted;

//SPDX-Licence-Identifier: GNU AGPL
pragma solidity >= 0.5.0 < 0.9.0;

contract Election{
    struct Candidate{
        string name;
        uint numVotes;
}
    struct Voter{
        string name;
        bool authorised;
        uint whom;
        bool voted;

    }

    address public owner;
    string public electionName;
    
    mapping (address => Voter) public voters;
    Candidate [] public candidates;
    uint public totalVotes;

    modifier ownerOnly(){
        require(msg.sender == owner);
        _;
    }

    function startElection(string memory _electionName) public{
        owner = msg.sender;
        electionName = _electionName;
    }

    function addCandidate(string memory _candidateName) ownerOnly public{
        candidates.push(Candidate(_candidateName, 0));

    }

    function authorizeVoter(address _voterAdress) ownerOnly public{
        voters[_voterAdress] authorised = true;
    }

    function getNumCandidates() public view return(uint){
        return candidates.length;
    }

    function vote(uint candidateIndex) public{
        require(!voters[msg.sender].voted);
        require(voters[msg.sender].authorised);
        voters[msg.sender].whom = candidateIndex;
    }
 
}//SPDX-Licence-Identifier: GNU AGPL
pragma solidity >= 0.5.0 < 0.9.0;

contract Election{
    struct Candidate{
        string name;
        uint numVotes;
}
    struct Voter{
        string name;
        bool authorised;
        uint whom;
        bool voted;

    }

    address public owner;
    string public electionName;
    
    mapping (address => Voter) public voters;
    Candidate [] public candidates;
    uint public totalVotes;

    modifier ownerOnly(){
        require(msg.sender == owner);
        _;
    }

    function startElection(string memory _electionName) public{
        owner = msg.sender;
        electionName = _electionName;
    }

    function addCandidate(string memory _candidateName) ownerOnly public{
        candidates.push(Candidate(_candidateName, 0));

    }

    function authorizeVoter(address _voterAdress) ownerOnly public{
        voters[_voterAdress] authorised = true;
    }

    function getNumCandidates() public view return(uint){
        return candidates.length;
    }

    function vote(uint candidateIndex) public{
        require(!voters[msg.sender].voted);
        require(voters[msg.sender].authorised);
        voters[msg.sender].whom = candidateIndex;
    }
 
}//SPDX-Licence-Identifier: GNU AGPL
pragma solidity >= 0.5.0 < 0.9.0;

contract Election{
    struct Candidate{
        string name;
        uint numVotes;
}
    struct Voter{
        string name;
        bool authorised;
        uint whom;
        bool voted;

    } 

    address public owner;
    string public electionName;
    
    mapping (address => Voter) public voters;
    Candidate [] public candidates;
    uint public totalVotes;

    modifier ownerOnly(){
        require(msg.sender == owner);
        _;
    }

    function startElection(string memory _electionName) public{
        owner = msg.sender;
        electionName = _electionName;
    }

    function addCandidate(string memory _candidateName) ownerOnly public{
        candidates.push(Candidate(_candidateName, 0));

    }

    function authorizeVoter(address _voterAdress) ownerOnly public{
        voters[_voterAdress] authorised = true;
    }

    function getNumCandidates() public view return(uint){
        return candidates.length;
    }

    function vote(uint candidateIndex) public{
        require(!voters[msg.sender].voted);
        require(voters[msg.sender].authorised);
        voters[msg.sender].whom = candidateIndex;
    }
 
}

}

//SPDX-Licence-Identifier: GNU AGPL pragma solidity >= 0.5.0 < 0.9.0;

contract Election{ struct Candidate{ string name; uint numVotes; } struct Voter{ string name; bool authorised; uint whom; bool voted;

}

address public owner;
string public electionName;

mapping (address => Voter) public voters;
Candidate [] public candidates;
uint public totalVotes;

modifier ownerOnly(){
    require(msg.sender == owner);
    _;
}

function startElection(string memory _electionName) public{
    owner = msg.sender;
    electionName = _electionName;
}

function addCandidate(string memory _candidateName) ownerOnly public{
    candidates.push(Candidate(_candidateName, 0));

}

function authorizeVoter(address _voterAdress) ownerOnly public{
    voters[_voterAdress] authorised = true;
}

function getNumCandidates() public view return(uint){
    return candidates.length;
}

function vote(uint candidateIndex) public{
    require(!voters[msg.sender].voted);
    require(voters[msg.sender].authorised);
    voters[msg.sender].whom = candidateIndex;
}

}

//SPDX-Licence-Identifier: GNU AGPL
pragma solidity >= 0.5.0 < 0.9.0;

contract Election{
    struct Candidate{
        string name;
        uint numVotes;
}
    struct Voter{
        string name;
        bool authorised;
        uint whom;
        bool voted;

    }

    address public owner;
    string public electionName;
    
    mapping (address => Voter) public voters;
    Candidate [] public candidates;
    uint public totalVotes;

    modifier ownerOnly(){
        require(msg.sender == owner);
        _;
    }

    function startElection(string memory _electionName) public{
        owner = msg.sender;
        electionName = _electionName;
    }

    function addCandidate(string memory _candidateName) ownerOnly public{
        candidates.push(Candidate(_candidateName, 0));

    }

    function authorizeVoter(address _voterAdress) ownerOnly public{
        voters[_voterAdress] authorised = true;
    }

    function getNumCandidates() public view return(uint){
        return candidates.length;
    }

    function vote(uint candidateIndex) public{
        require(!voters[msg.sender].voted);
        require(voters[msg.sender].authorised);
        voters[msg.sender].whom = candidateIndex;
    }
 
}//SPDX-Licence-Identifier: GNU AGPL
pragma solidity >= 0.5.0 < 0.9.0;

contract Election{
    struct Candidate{
        string name;
        uint numVotes;
}
    struct Voter{
        string name;
        bool authorised;
        uint whom;
        bool voted;

    }

    address public owner;
    string public electionName;
    
    mapping (address => Voter) public voters;
    Candidate [] public candidates;
    uint public totalVotes;

    modifier ownerOnly(){
        require(msg.sender == owner);
        _;
    }

    function startElection(string memory _electionName) public{
        owner = msg.sender;
        electionName = _electionName;
    }

    function addCandidate(string memory _candidateName) ownerOnly public{
        candidates.push(Candidate(_candidateName, 0));

    }

    function authorizeVoter(address _voterAdress) ownerOnly public{
        voters[_voterAdress] authorised = true;
    }

    function getNumCandidates() public view return(uint){
        return candidates.length;
    }

    function vote(uint candidateIndex) public{
        require(!voters[msg.sender].voted);
        require(voters[msg.sender].authorised);
        voters[msg.sender].whom = candidateIndex;
    }
 
}//SPDX-Licence-Identifier: GNU AGPL
pragma solidity >= 0.5.0 < 0.9.0;

contract Election{
    struct Candidate{
        string name;
        uint numVotes;
}
    struct Voter{
        string name;
        bool authorised;
        uint whom;
        bool voted;

    } 

    address public owner;
    string public electionName;
    
    mapping (address => Voter) public voters;
    Candidate [] public candidates;
    uint public totalVotes;

    modifier ownerOnly(){
        require(msg.sender == owner);
        _;
    }

    function startElection(string memory _electionName) public{
        owner = msg.sender;
        electionName = _electionName;
    }

    function addCandidate(string memory _candidateName) ownerOnly public{
        candidates.push(Candidate(_candidateName, 0));

    }

    function authorizeVoter(address _voterAdress) ownerOnly public{
        voters[_voterAdress] authorised = true;
    }

    function getNumCandidates() public view return(uint){
        return candidates.length;
    }

    function vote(uint candidateIndex) public{
        require(!voters[msg.sender].voted);
        require(voters[msg.sender].authorised);
        voters[msg.sender].whom = candidateIndex;
    }
 
}
added 52 characters in body
Source Link

//SPDX-Licence-Identifier: GNU AGPL pragma solidity >= 0.5.0 < 0.9.0;

contract Election{ struct Candidate{ string name; uint numVotes; } struct Voter{ string name; bool authorised; uint whom; bool voted;

pragma solidity >= 0.5.0 < 0.9.0;

contract Election{
    struct Candidate{}
        string name;
        uint numVotes;
}
    struct Voter{
        string name;
        bool authorised;
        uint whom;
        bool voted;

    }

    address public owner;
    string public electionName;
    
    mapping (address => Voter) public voters;
    Candidate [] public candidates;
    uint public totalVotes;

    modifier ownerOnly(){
        require(msg.sender == owner);
        _;
    }

    function startElection(string memory _electionName) public{
        owner = msg.sender;
        electionName = _electionName;
    }

    function addCandidate(string memory _candidateName) ownerOnly public{
        candidates.push(Candidate(_candidateName, 0));

    }

    function authorizeVoter(address _voterAdress) ownerOnly public{
        voters[_voterAdress] authorised = true;
    }

    function getNumCandidates() public view return(uint){
    return candidates.length;
}

function vote(uint candidateIndex) public{
   return candidatesrequire(!voters[msg.length;sender].voted);
    }require(voters[msg.sender].authorised);
    voters[msg.sender].whom = candidateIndex;
}

}

error text : ElectionElection.sol:943:545: ParserError: Expected pragma, import directive or contract/interface/library definition.'{' but got 'return' struct Voterfunction getNumCandidates() public view return(uint){ ^----^

pragma solidity >= 0.5.0 < 0.9.0;

contract Election{
    struct Candidate{}
        string name;
        uint numVotes;
}
    struct Voter{
        string name;
        bool authorised;
        uint whom;
        bool voted;

    }

    address public owner;
    string public electionName;
    
    mapping (address => Voter) public voters;
    Candidate [] public candidates;
    uint public totalVotes;

    modifier ownerOnly(){
        require(msg.sender == owner);
        _;
    }

    function startElection(string memory _electionName) public{
        owner = msg.sender;
        electionName = _electionName;
    }

    function addCandidate(string memory _candidateName) ownerOnly public{
        candidates.push(Candidate(_candidateName, 0))

    }

    function authorizeVoter(address _voterAdress) ownerOnly public{
        voters[_voterAdress] authorised = true;
    }

    function getNumCandidates() public view return(uint){
        return candidates.length;
    }
 
}

error text : Election.sol:9:5: ParserError: Expected pragma, import directive or contract/interface/library definition. struct Voter{ ^----^

//SPDX-Licence-Identifier: GNU AGPL pragma solidity >= 0.5.0 < 0.9.0;

contract Election{ struct Candidate{ string name; uint numVotes; } struct Voter{ string name; bool authorised; uint whom; bool voted;

}

address public owner;
string public electionName;

mapping (address => Voter) public voters;
Candidate [] public candidates;
uint public totalVotes;

modifier ownerOnly(){
    require(msg.sender == owner);
    _;
}

function startElection(string memory _electionName) public{
    owner = msg.sender;
    electionName = _electionName;
}

function addCandidate(string memory _candidateName) ownerOnly public{
    candidates.push(Candidate(_candidateName, 0));

}

function authorizeVoter(address _voterAdress) ownerOnly public{
    voters[_voterAdress] authorised = true;
}

function getNumCandidates() public view return(uint){
    return candidates.length;
}

function vote(uint candidateIndex) public{
    require(!voters[msg.sender].voted);
    require(voters[msg.sender].authorised);
    voters[msg.sender].whom = candidateIndex;
}

}

error text :Election.sol:43:45: ParserError: Expected '{' but got 'return' function getNumCandidates() public view return(uint){ ^----^

added 182 characters in body
Source Link
pragma solidity >= 0.5.0 < 0.9.0;

contract Election{ struct Candidate{} string name; uint numVotes; } struct Voter{ string name; bool authorised; uint whom; bool voted;


contract Election{
    struct Candidate{}
        string name;
        uint numVotes;
}
    struct Voter{
        string name;
        bool authorised;
        uint whom;
        bool voted;

    }

    address public owner;
    string public electionName;
    
    mapping (address => Voter) public voters;
    Candidate [] public candidates;
    uint public totalVotes;

    modifier ownerOnly(){
        require(msg.sender == owner);
        _;
    }

    function startElection(string memory _electionName) public{
        owner = msg.sender;
        electionName = _electionName;
    }

    function addCandidate(string memory _candidateName) ownerOnly public{
        candidates.push(Candidate(_candidateName, 0))

    }

    function authorizeVoter(address _voterAdress) ownerOnly public{
        voters[_voterAdress] authorised = true;
    }

    function getNumCandidates() public view return(uint){
        return candidates.length;
    }
 
}

}

error text : Election.sol:9:5: ParserError: Expected pragma, import directive or contract/interface/library definition. struct Voter{ ^----^

pragma solidity >= 0.5.0 < 0.9.0;

contract Election{ struct Candidate{} string name; uint numVotes; } struct Voter{ string name; bool authorised; uint whom; bool voted;

}

address public owner;
string public electionName;

mapping (address => Voter) public voters;
Candidate [] public candidates;
uint public totalVotes;

modifier ownerOnly(){
    require(msg.sender == owner);
    _;
}

function startElection(string memory _electionName) public{
    owner = msg.sender;
    electionName = _electionName;
}

function addCandidate(string memory _candidateName) ownerOnly public{
    candidates.push(Candidate(_candidateName, 0))

}

function authorizeVoter(address _voterAdress) ownerOnly public{
    voters[_voterAdress] authorised = true;
}

function getNumCandidates() public view return(uint){
    return candidates.length;
}

}

error text : Election.sol:9:5: ParserError: Expected pragma, import directive or contract/interface/library definition. struct Voter{ ^----^

pragma solidity >= 0.5.0 < 0.9.0;

contract Election{
    struct Candidate{}
        string name;
        uint numVotes;
}
    struct Voter{
        string name;
        bool authorised;
        uint whom;
        bool voted;

    }

    address public owner;
    string public electionName;
    
    mapping (address => Voter) public voters;
    Candidate [] public candidates;
    uint public totalVotes;

    modifier ownerOnly(){
        require(msg.sender == owner);
        _;
    }

    function startElection(string memory _electionName) public{
        owner = msg.sender;
        electionName = _electionName;
    }

    function addCandidate(string memory _candidateName) ownerOnly public{
        candidates.push(Candidate(_candidateName, 0))

    }

    function authorizeVoter(address _voterAdress) ownerOnly public{
        voters[_voterAdress] authorised = true;
    }

    function getNumCandidates() public view return(uint){
        return candidates.length;
    }
 
}

error text : Election.sol:9:5: ParserError: Expected pragma, import directive or contract/interface/library definition. struct Voter{ ^----^

added 62 characters in body
Source Link
Loading
added 4 characters in body
Source Link
Loading
added 441 characters in body
Source Link
Loading
Source Link
Loading