Created
August 9, 2022 21:50
-
-
Save AyDeveloper/d89b7a3684ad661e7cb9486049435ced to your computer and use it in GitHub Desktop.
This file contains 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: Unlicensed | |
pragma solidity ^0.8.0; | |
abstract contract HelloWorld { | |
string public message; | |
constructor(string memory _message){ | |
message = _message; | |
} | |
function getMessage() public virtual view returns (string memory){ | |
return message; | |
} | |
function setMessage(string memory _message) public virtual {} | |
function defaultMessage() public pure returns (string memory) | |
{ | |
return "Hello World"; | |
} | |
} | |
contract UseHelloWorld is HelloWorld { | |
uint public num; | |
constructor(string memory _message, uint _num) HelloWorld(_message){ | |
num = _num; | |
} | |
function setNum(uint _num ) public { | |
num = _num; | |
} | |
function getNum() public virtual view returns (uint256){ | |
return num; | |
} | |
function defaultNum() public pure returns (uint256){ | |
return 50; | |
} | |
function setMessage(string memory _message ) public override virtual { | |
message = _message; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment