Created
August 14, 2023 05:17
-
-
Save Ifeanyi-Ani/7484296ee21df44a65f46e250fe993d2 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.18+commit.87f61d96.js&optimize=false&runs=200&gist=
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.18; | |
// FIRST CHALLENGE | |
// Write a simple contract and declare four different types of variables. | |
// Write get and set functions for each of these variables. | |
//Return the value of the variable in the “set function”. | |
contract ChallengeOne { | |
bool public check; | |
int public number; | |
uint public value; | |
string public read; | |
// setting variables | |
function setcheck(bool _check) public { | |
check = _check; | |
} | |
function setNumber(int _number) public { | |
number = _number; | |
} | |
function setValue(uint _value) public { | |
value = _value; | |
} | |
function setRead(string memory _read) public { | |
read = _read; | |
} | |
// getting variables | |
function getcheck() public view returns (bool) { | |
return check; | |
} | |
function getNumber() public view returns (int) { | |
return number; | |
} | |
function getValue() public view returns (uint) { | |
return value; | |
} | |
function getRead() public view returns (string memory) { | |
return read; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solidity first challenge