Created
October 28, 2016 12:20
-
-
Save agatsoh/9f6a57b735c679b392e306edc2f7ab77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.2; | |
contract Account{ | |
int public variableAB; | |
int public variableBA; | |
int public balanceAB; | |
function Account(int variableAB, int variableBA){ | |
variableAB = variableAB; | |
variableBA = variableBA; | |
} | |
function setLines(int variableAB, int variableBA){ | |
variableAB = variableAB; | |
variableBA = variableBA; | |
} | |
function setBalance(int balanceAB){ | |
balanceAB = balanceAB; | |
} | |
} | |
contract TLTokenMap{ | |
mapping(bytes32 => Account) accounts; | |
function approve(bytes32 name, int variableAB, int variableBA){ | |
Account account = accounts[name]; | |
if(address(account) == address(0)){ | |
address newAccount = new Account(variableAB, variableBA); | |
accounts[name] = Account(newAccount); | |
}else{ | |
account.setLines(variableAB, variableBA); | |
} | |
} | |
function generateBalance(bytes32 name, int balanceAB){ | |
Account account = accounts[name]; | |
if(address(account) == address(0)){ | |
return; | |
}else{ | |
account.setBalance(balanceAB); | |
} | |
} | |
function getAccount(bytes32 name) constant returns (int, int, int){ | |
Account account = accounts[name]; | |
if(address(account) == address(0)){ | |
return (0, 0, 0); | |
}else{ | |
return (account.variableAB(), account.variableBA(), account.balanceAB()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment