-
Notifications
You must be signed in to change notification settings - Fork 0
/
Courses.sol
58 lines (46 loc) · 1.31 KB
/
Courses.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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;
}
event instructorInfo(
bytes16 fName,
bytes16 lName,
uint age
);
mapping (address => Instructor) instructors;
address[] public instructorAccounts;
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;
instructorAccounts.push(_address) -1;
instructorInfo(_fname, _lname, _age);
}
function getInstructors() view public returns (address[]) {
return instructorAccounts;
}
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 instructorAccounts.length;
}
}