SHARE
TWEET

Untitled

a guest Mar 20th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. pragma solidity 0.4.24;
  2.  
  3. interface Regulator {
  4.     function checkValue(uint amount) external returns (bool);
  5.     function loan() external returns (bool);
  6. }
  7.  
  8.  
  9. contract Bank is Regulator {
  10.     uint private value;
  11.     address private owner;
  12.    
  13.     modifier ownerFunc {
  14.         require(owner == msg.sender);
  15.         _;
  16.     }
  17.    
  18.     function Bank(uint amount) {
  19.         value = amount;
  20.         owner = msg.sender;
  21.     }
  22.    
  23.     function deposit(uint amount) ownerFunc{
  24.         value += amount;
  25.     }
  26.    
  27.     function withdraw(uint amount) ownerFunc{
  28.         if(checkValue(amount)){
  29.             value -= amount;
  30.         }
  31.     }
  32.    
  33.     function balance() returns (uint) {
  34.         return value;
  35.     }
  36.        
  37.     function checkValue(uint amount) returns (bool){
  38.         return amount >= value;
  39.     }
  40.    
  41.     function loan() returns (bool) {
  42.         return value > 0;
  43.     }
  44. }
  45.  
  46. contract MyFirstContract is Bank(10) {
  47.     string private name;
  48.     uint private age;
  49.    
  50.     function setName(string newName) {
  51.         name = newName;
  52.     }
  53.    
  54.     function getName() returns (string) {
  55.         return name;
  56.     }
  57.    
  58.     function setAge(uint newAge) {
  59.         age = newAge;
  60.     }
  61.    
  62.     function getAge() returns (uint) {
  63.         return age;
  64.     }
  65. }
  66.  
  67. contract TestThrows {
  68.     function testAssert(){
  69.         assert(1 == 2);
  70.     }
  71.    
  72.     function testRequire(){
  73.         require(2 == 1);
  74.     }
  75.    
  76.     function testRevert(){
  77.         revert();
  78.     }
  79.    
  80.     function testThrow(){
  81.         throw;
  82.     }
  83. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top