-
-
Save MihaiWill/2144c58e56584573335bc022fc0ce2e2 to your computer and use it in GitHub Desktop.
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.19+commit.c4cbbb05.js&optimize=false&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
pragma solidity ^0.4.18; | |
contract Coursetro { | |
string fName; | |
uint age; | |
address owner; | |
event Instructor( | |
string name, | |
uint age | |
); | |
function Coursetro() public { | |
owner = msg.sender; | |
} | |
modifier onlyOwner { | |
require(msg.sender == owner); | |
_; | |
} | |
function setInstructor(string _fName, uint _age) onlyOwner public { | |
fName = _fName; | |
age = _age; | |
Instructor(fName, _age); | |
} | |
function getInstructor() public constant returns (string, uint) { | |
return (fName, age); | |
} | |
} |
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
pragma solidity ^0.4.18; | |
contract Owned { | |
address owner; | |
function Owned() public { | |
owner = msg.sender; | |
} | |
modifier onlyOwner { | |
require(msg.sender == owner); | |
_; | |
} | |
} | |
contract Courses is Owned { | |
struct Instructor { | |
uint age; | |
bytes16 fName; | |
bytes16 lName; | |
} | |
mapping (address => Instructor) instructors; | |
address[] public instructorAccts; | |
event instructorInfo( | |
bytes16 fName, | |
bytes16 lName, | |
uint age | |
); | |
function setInstructor(address _address, uint _age, bytes16 _fName, bytes16 _lName) onlyOwner public { | |
var instructor = instructors[_address]; | |
instructor.age = _age; | |
instructor.fName = _fName; | |
instructor.lName = _lName; | |
instructorAccts.push(_address) -1; | |
instructorInfo(_fName, _lName, _age); | |
} | |
function getInstructors() view public returns(address[]) { | |
return instructorAccts; | |
} | |
function getInstructor(address _address) view public returns (uint, bytes16, bytes16) { | |
return (instructors[_address].age, instructors[_address].fName, instructors[_address].lName); | |
} | |
function countInstructors() view public returns (uint) { | |
return instructorAccts.length; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment