-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathbase3
More file actions
34 lines (28 loc) · 823 Bytes
/
base3
File metadata and controls
34 lines (28 loc) · 823 Bytes
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
contract CounterV3 {
uint public count;
uint public step;
constructor(uint _initial, uint _step) {
count = _initial;
step = _step;
}
// step kadar artır
function increment() public {
count += step;
}
// step kadar azalt (0’ın altına düşemez)
function decrement() public {
require(count >= step, "Counter: value cannot be negative");
count -= step;
}
// step değerini güncelle
function setStep(uint _newStep) public {
require(_newStep > 0, "Step must be greater than 0");
step = _newStep;
}
// sayacın 2 katını döndürür (ekstra örnek fonksiyon)
function getDouble() public view returns (uint) {
return count * 2;
}
}