-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcon.sol
63 lines (51 loc) · 1.13 KB
/
con.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.15;
enum State {
Waiting,
Active,
Ready
}
struct Person {
string _firstName;
string _lastName;
}
contract MyContract {
string public value = "initial Value";
State public state = State.Waiting;
Person[] public people;
uint256 public peopleCount = 0;
mapping(uint256 => Person) public peopleMap;
address owner;
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
constructor() {
owner = msg.sender;
}
function setValue(string memory _value) public {
value = _value;
}
function activate() public {
state = State.Active;
}
function isActive() public view returns (bool) {
return state == State.Active;
}
function addPerson(string memory _firstName, string memory _lastName)
public
onlyOwner
{
people.push(Person(_firstName, _lastName));
}
function addPersonToMap(string memory _firstName, string memory _lastName)
public
onlyOwner
{
incrementCount();
peopleMap[peopleCount] = Person(_firstName, _lastName);
}
function incrementCount() internal {
peopleCount += 1;
}
}