Created
December 13, 2023 12:50
-
-
Save Scofield-Idehen/bca5c823488c7cb3b22aa834fbe8054f 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.22+commit.4fc1097e.js&optimize=false&runs=200&gist=
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: MIT | |
pragma solidity ^0.8.16; | |
import {scofield} from "./new1.sol"; | |
contract addinherietance is scofield{ | |
function store(uint _addnewfive) public override { | |
number = _addnewfive +5; | |
} | |
} |
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: MIT | |
pragma solidity ^0.8.18; // solidity version | |
contract scofield { | |
//number gets initialized to zero if no number is added | |
uint public number; | |
mapping (string => uint256) public findname; | |
//array of numbers | |
//uint [] array_number; | |
struct Person{ | |
uint new_number; | |
string name; | |
} | |
//static and dynamic array | |
Person[] public scofieldArray; | |
// this adds a new item to the list of the array!!! | |
// Person public scofield = Person({new_number: 9, name: "valencia"}); | |
function store (uint _number) public virtual { | |
number = _number; | |
} | |
// view pure disallow updating the state of the function | |
function retrieve() public view returns (uint){ | |
return number; | |
} | |
//this function takes the array and adds a new user to the list, name.push | |
//to the struct Person | |
//so you say name.push(struct of the values equals to what is inside the struct | |
function addnew(string memory _name, uint _new_number) public { | |
scofieldArray.push(Person(_new_number, _name)); | |
findname[_name] = _new_number; | |
} | |
} |
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: MIT | |
pragma solidity ^0.8.17; | |
import {testing} from './test.sol'; | |
contract advancetest{ | |
testing public Test; | |
function testcon() public { | |
Test = new testing(); | |
} | |
} |
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: MIT | |
pragma solidity ^0.8.18; | |
// this only import the exact contract and do not import like this | |
// import './new1.sol'; | |
import {scofield} from "./new1.sol"; | |
contract update_contract{ | |
// this would not keep track of all the contract so we need to make it an array | |
//contract veraible | |
//scofield public Scofield; | |
scofield[] public listofScofieldcontract; | |
function get_new_contract() public{ | |
scofield newlist = new scofield(); | |
listofScofieldcontract.push(newlist); | |
} | |
function store (uint _index, uint storeNumber) public { | |
listofScofieldcontract[_index].store(storeNumber); | |
} | |
function getValue(uint _storeindex) public view returns (uint){ | |
return listofScofieldcontract[_storeindex].retrieve(); | |
} | |
} |
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: MIT | |
pragma solidity ^0.8.7; | |
contract testing{ | |
struct Person{ | |
string name; | |
uint valueNumber; | |
} | |
Person[] public NewPerson; | |
mapping (string => uint) public new_map; | |
function listname(string memory _name, uint _valueNumber) public { | |
NewPerson.push(Person(_name, _valueNumber)); | |
new_map[_name]= _valueNumber; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment