Guest User

Untitled

a guest
Feb 21st, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. pragma solidity ^0.4.18;
  2.  
  3. contract Owned {
  4. address owner;
  5.  
  6. function Owned() public {
  7. owner = msg.sender;
  8. }
  9.  
  10. modifier onlyOwner {
  11. require(msg.sender == owner);
  12. _;
  13. }
  14. }
  15.  
  16. contract Courses is Owned {
  17.  
  18. struct Instructor {
  19. uint age;
  20. bytes16 fName;
  21. bytes16 lName;
  22. }
  23.  
  24. mapping (address => Instructor) instructors;
  25. address[] public instructorAccts;
  26.  
  27. event instructorInfo(
  28. bytes16 fName,
  29. bytes16 lName,
  30. uint age
  31. );
  32.  
  33. function setInstructor(address _address, uint _age, bytes16 _fName, bytes16 _lName) onlyOwner public {
  34. var instructor = instructors[_address];
  35.  
  36. instructor.age = _age;
  37. instructor.fName = _fName;
  38. instructor.lName = _lName;
  39.  
  40. instructorAccts.push(_address) -1;
  41. instructorInfo(_fName, _lName, _age);
  42. }
  43.  
  44. function getInstructors() view public returns(address[]) {
  45. return instructorAccts;
  46. }
  47.  
  48. function getInstructor(address _address) view public returns (uint, bytes16, bytes16) {
  49. return (instructors[_address].age, instructors[_address].fName, instructors[_address].lName);
  50. }
  51.  
  52. function countInstructors() view public returns (uint) {
  53. return instructorAccts.length;
  54. }
  55.  
  56. }
Add Comment
Please, Sign In to add comment