mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
Create S
This commit is contained in:
parent
891bbad9ce
commit
7346735851
1 changed files with 37 additions and 0 deletions
37
S
Normal file
37
S
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
pragma solidity 0.8.17;
|
||||||
|
|
||||||
|
contract ControlStructures {
|
||||||
|
error AfterHours(uint256 time);
|
||||||
|
error AtLunch();
|
||||||
|
|
||||||
|
function fizzBuzz(uint256 _number) public pure returns (string memory response) {
|
||||||
|
if (_number % 3 == 0 && _number % 5 == 0) {
|
||||||
|
return "FizzBuzz";
|
||||||
|
} else if (_number % 3 == 0) {
|
||||||
|
return "Fizz";
|
||||||
|
} else if (_number % 5 == 0) {
|
||||||
|
return "Buzz";
|
||||||
|
} else {
|
||||||
|
return "Splat";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function doNotDisturb(uint256 _time) public pure returns (string memory result) {
|
||||||
|
assert(_time < 2400);
|
||||||
|
|
||||||
|
if (_time > 2200 || _time < 800) {
|
||||||
|
revert AfterHours(_time);
|
||||||
|
} else if (_time >= 1200 && _time <= 1299) {
|
||||||
|
revert("At lunch!");
|
||||||
|
} else if (_time >= 800 && _time <= 1199) {
|
||||||
|
return "Morning!";
|
||||||
|
} else if (_time >= 1300 && _time <= 1799) {
|
||||||
|
return "Afternoon!";
|
||||||
|
} else if (_time >= 1800 && _time <= 2200) {
|
||||||
|
return "Evening!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in a new issue