Skip to content

Instantly share code, notes, and snippets.

Created February 8, 2018 19:20
Show Gist options
  • Save anonymous/185b6ae055b7217811f7c18b533196f7 to your computer and use it in GitHub Desktop.
Save anonymous/185b6ae055b7217811f7c18b533196f7 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=
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);
}
}
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