Created
June 21, 2018 15:04
-
-
Save jigar23/b3bf81adf7ef13a37510136299573388 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.4.23+commit.124ca40d.js&optimize=false&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
pragma solidity ^0.4.0; | |
interface Letter { | |
function n() external returns (uint); | |
} | |
contract A is Letter { | |
function n() public returns (uint) { | |
return 1; | |
} | |
} | |
contract B is Letter { | |
function n() public returns (uint) { | |
return 2; | |
} | |
} | |
contract C is Letter { | |
function n() public returns (uint) { | |
return 3; | |
} | |
} | |
contract Alphabet { | |
Letter[] private letters; | |
event Printer(uint); | |
constructor() public { | |
A a = new A(); | |
letters.push(a); | |
letters.push(new B()); | |
letters.push(new C()); | |
} | |
function print() public { | |
for (uint i = 0; i < letters.length; i++) { | |
emit Printer(letters[i].n()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment