-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpeningTime.sol
37 lines (22 loc) · 923 Bytes
/
OpeningTime.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
pragma solidity 0.8.5;
contract MyContract {
uint256 public peopleCount = 0;
mapping(uint => Person) public people;
uint256 openingTime = 1623815570;
modifier onlyWhileOpen() { // function modifier are used to modify the behaviour of the function or add a prerequisite to function
require(block.timestamp >= openingTime);
_; //definition of the modifier, it is a rule that a modifier should have this special symbol
}
struct Person {
uint _id;
string _fistName;
string _lastName;
}
function addPerson (string memory _fistName, string memory _lastName) public onlyWhileOpen{
incrementCount();
people[peopleCount] = Person(peopleCount, _fistName, _lastName);
}
function incrementCount() internal {
peopleCount +=1;
}
}