Skip to content

Instantly share code, notes, and snippets.

@AyDeveloper
Created August 9, 2022 21:50
Show Gist options
  • Save AyDeveloper/d89b7a3684ad661e7cb9486049435ced to your computer and use it in GitHub Desktop.
Save AyDeveloper/d89b7a3684ad661e7cb9486049435ced to your computer and use it in GitHub Desktop.
// 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