tsnaik

Courses Contract | First | Coursetro

May 27th, 2018
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. pragma solidity ^0.4.18;
  2.  
  3. contract Courses {
  4.  
  5. struct Instructor {
  6. uint age;
  7. string fname;
  8. string lname;
  9. }
  10.  
  11. mapping (address => Instructor) instructors;
  12.  
  13. address[] public instructorAccounts;
  14.  
  15. function setInstructor(address _address, uint _age, string _fname, string _lname) public {
  16. Instructor storage instructor = instructors[_address];
  17.  
  18. instructor.age = _age;
  19. instructor.fname = _fname;
  20. instructor.lname = _lname;
  21.  
  22. instructorAccounts.push(_address) -1;
  23. }
  24.  
  25. function getInstructors() view public returns(address[]) {
  26. return instructorAccounts;
  27. }
  28.  
  29. function getInstructor(address _address) view public returns(uint, string, string) {
  30. return (instructors[_address].age, instructors[_address].fname, instructors[_address].lname);
  31. }
  32.  
  33. function countInstructors() view public returns(uint) {
  34. return instructorAccounts.length;
  35. }
  36. }
Add Comment
Please, Sign In to add comment