Guest User

Untitled

a guest
Jan 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. pragma solidity ^0.4.17;
  2.  
  3. interface Regulator {
  4. function checkBalance(uint amount)public returns(bool);
  5.  
  6. }
  7.  
  8. contract Bank is Regulator{
  9. uint private value;
  10.  
  11. function Bank(uint _amount) public {
  12. value = _amount;
  13. }
  14.  
  15. function deposit(uint amount) public {
  16. value += amount;
  17. }
  18.  
  19. function withdrawl(uint amount) public {
  20. if(checkBalance(amount)){
  21. value -= amount;
  22. }
  23.  
  24. }
  25.  
  26. function checkBalance(uint amount) public returns(bool){
  27. return value >= amount;
  28. }
  29.  
  30. function balance()view public returns (uint) {
  31. return value;
  32. }
  33. }
  34.  
  35. contract Person is Bank(10){
  36. bytes16 private name;
  37. uint private age;
  38.  
  39. function setName(bytes16 _name) public {
  40. name = _name;
  41. }
  42.  
  43. function setAget(uint _age) public {
  44. age = _age;
  45. }
  46.  
  47. function getAge() view public returns(uint){
  48. return age;
  49. }
  50.  
  51. function getName() view public returns(string){
  52. bytes memory bytesArray = new bytes(16);
  53. for (uint256 i; i < 16; i++) {
  54. bytesArray[i] = name[i];
  55. }
  56. return string(bytesArray);
  57.  
  58. }
  59.  
  60.  
  61. }
Add Comment
Please, Sign In to add comment