forked from AlizadeAlireza/Simple_Counter_solidity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCounter.sol
More file actions
54 lines (39 loc) · 1.2 KB
/
Counter.sol
File metadata and controls
54 lines (39 loc) · 1.2 KB
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
contract Counter {
int256 public count;
// Function to get the current count
// function get() public view returns (int256) {
// // the current count is:
// return count;
// }
// count public don't need to get function
modifier firstNeed {
require(count != 0 ,"Please increase or decrease the count first.");
_;
}
// function to increament count by 1
function increaseByOne() public {
count += 1;
}
// function to decreament count by 1
function decreaseByOne() public {
count -= 1;
}
// function to increament count by given number
function increase(int256 _elevator) public{
count += _elevator;
}
// function to decreament count by given number
function decrease(int256 _reducer) public{
count -= _reducer;
}
// function to multiply count by given number
function multiply(int256 _modulus) firstNeed public{
count *= _modulus;
}
// function to divide count by given number
function divide(int256 _div) firstNeed public{
count /= _div;
}
}