-
Notifications
You must be signed in to change notification settings - Fork 2
/
004-decision-making.sol
44 lines (36 loc) · 1.06 KB
/
004-decision-making.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
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
/**
* Learn about decision making in solidity
* conditional statements, switching execution paths
* based on certain conditions or decision made
*/
contract LearnDecisionMaking {
// orange variable
uint256 oranges = 5;
// validate oranges function
function validateOranges() public view returns (bool) {
// if...else condition
if (oranges == 5) // evaluates trueness of the expression in parenthesis
{
// then
return true;
} else {
return false;
}
}
// exercise
uint256 stakingWallet = 10;
// stake more and ge more, stake less you get less
function airDrop() public view returns (uint256) {
if (stakingWallet == 10) {
return stakingWallet + 10;
} else {
return stakingWallet + 1;
}
}
function airDropTwo() public view returns (uint256) {
if (stakingWallet == 10) return stakingWallet + 10;
return stakingWallet + 1;
}
}