Nik_Perepelov

блокчейн-дверь

Dec 22nd, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. pragma solidity >=0.5.0 <0.5.12;
  2. contract SmartDoor{
  3. uint8 hour;
  4. uint8 minute;
  5. uint8 second;
  6. // True - закрытие двери, False - открытие двери
  7. bool last_action;
  8. constructor() public{
  9. hour = 0;
  10. minute = 0;
  11. second = 0;
  12. last_action = true;
  13. }
  14. function closeDoor(uint8 t_hour, uint8 t_minute, uint8 t_second) public{
  15. require(last_action == false);
  16. hour = t_hour;
  17. minute = t_minute;
  18. second = t_second;
  19.  
  20. }
  21. function openDoor(uint8 t_hour, uint8 t_minute, uint8 t_second) public{
  22. require(last_action == true);
  23. hour = t_hour;
  24. minute = t_minute;
  25. second = t_second;
  26. }
  27. function getStatus() public view returns (uint8, uint8, uint8, bool){
  28. return (hour, minute, second, last_action);
  29. }
  30. }
Add Comment
Please, Sign In to add comment