Skip to content

Commit 34b34b5

Browse files
committed
Added some Solidity files........
Pragma solidity 0.5.1 & 0.4.21 & 0.4.24 versions used.
1 parent fc24d77 commit 34b34b5

4 files changed

Lines changed: 87 additions & 24 deletions

File tree

Computer.sol

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
pragma solidity 0.5.1;
2+
contract Computer_State{
3+
enum State { Running, ShutDown, SavedState, Hibernated, Sleeped, Terminated }
4+
State public state;
5+
6+
constructor() public {
7+
state = State.Running;
8+
}
9+
function Terminate_Computer() public {
10+
state = State.Terminated;
11+
}
12+
function Start_Computer() public {
13+
state = State.Running;
14+
}
15+
function Stut_Down_Computer() public {
16+
state = State.ShutDown;
17+
}
18+
function Hibernate_Computer() public {
19+
state = State.Hibernated;
20+
}
21+
function Sleep_Computer() public {
22+
state = State.Sleeped;
23+
}
24+
function Save_Computer_State() public {
25+
state = State.SavedState
26+
}
27+
}

Election.sol

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
pragma solidity ^0.4.21;
2+
contract Election {
3+
struct Candidate {
4+
string name;
5+
uint voteCount;
6+
}
7+
struct Voter {
8+
bool authorized;
9+
bool voted;
10+
uint vote;
11+
}
12+
address public owner;
13+
string public electionName;
14+
mapping(address => Voter)public Voters;
15+
Candidate[] public candidates;
16+
uint public totalVotes;
17+
modifier ownerOnly() {
18+
require(msg.sender == owner);
19+
_;
20+
}
21+
function Election(string _name) public {
22+
owner == msg.sender;
23+
electionName = "Which Company is the best?";
24+
}
25+
function addCandidate(string name) ownerOnly public {
26+
candidates.push((Candidate(name, 0)));
27+
28+
}
29+
function getNumCandidate() public view returns(uint) {
30+
return candidates.length;
31+
}
32+
function authorize (address person)ownerOnly public {
33+
Voters[person].authorized = true;
34+
}
35+
function vote(uint voteIndex) public {
36+
require(!Voters[msg.sender].voted);
37+
require(Voters[msg.sender].authorized);
38+
Voters[msg.sender].vote = voteIndex;
39+
Voters[msg.sender].voted = true;
40+
candidates[voteIndex].voteCount += 1;
41+
totalVotes += 1;
42+
}
43+
function end()ownerOnly public{
44+
selfdestruct(owner);
45+
}
46+
}

Messages.sol

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
pragma solidity ^0.4.24;
2+
contract Message_SEND_AND_RECIEVE {
3+
string message ;
4+
5+
function SEND(string message_to_send) public {
6+
message = message_to_send;
7+
}
8+
function RETRIEVE() public constant returns(string) {
9+
return message;
10+
}
11+
}

Var-Types.sol

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,9 @@
1-
pragma solidity 0.8.0;
1+
pragma solidity 0.5.1;
22
contract Var_TypesCon {
33
string public stringVar = "Default";
44
bool public boolvar = true;
55
int public intvar = 1;
66
uint public uintvar = 1;
77
uint8 public uint8var = 8;
8-
uint256 public uint256var = 99999;
9-
function cstringVar(string memory stringVar1) public {
10-
stringVar = stringVar1;
11-
}
12-
function booltrue() public {
13-
boolvar = true;
14-
}
15-
function boolfalse() public {
16-
boolvar = false;
17-
}
18-
function cintvar(int intvar1) public {
19-
intvar = intvar1;
20-
}
21-
function cuintvar(uint uintvar1) public {
22-
uintvar = uintvar1;
23-
}
24-
function cintvar8(uint8 uint8var1) public {
25-
uint8var = uint8var1;
26-
}
27-
function cuint256(uint256 uint256var1) public {
28-
uint256var = uint256var1
29-
}
30-
}
8+
uint256 public uint256var = 99;
9+
}

0 commit comments

Comments
 (0)