pragma solidity ^0.4.0;
contract TransTest {
//
address public owner;
address[] public aaddress = new address[](1);
mapping(address=>uint) amoneycount;
address[] public baddress = new address[](1);
mapping(address=>uint) bmoneycount;
address[] public caddress = new address[](1);
mapping(address=>uint) cmoneycount;
bool isvoting = false;
function TransTest() public {
owner = msg.sender;
}
function voting(uint a) payable public returns (uint){
//地址===》投票 金额
require(isvoting);
if(a== 1){
aaddress.push(msg.sender);
amoneycount[msg.sender] = msg.value;
return aaddress.length;
}else if(a==2){
baddress.push(msg.sender);
bmoneycount[msg.sender] = msg.value;
return baddress.length;
}else if(a==0){
caddress.push(msg.sender);
cmoneycount[msg.sender] = msg.value;
return caddress.length;
}else{
return 0;
}
}
modifier isOwner(){
if(msg.sender==owner){
_;
}
}
function setVoting(bool isvoting2) public isOwner returns(bool){
isvoting = isvoting2;
return isvoting;
}
function getAL()public constant returns (uint){
return aaddress.length;
}
function getBL()public constant returns (uint){
return baddress.length;
}
function getCL()public constant returns (uint){
return caddress.length;
}
function getA(uint i) public constant returns (address,uint){
require(i<aaddress.length);
return (aaddress[i],amoneycount[aaddress[i]]);
}
function getB(uint i) public constant returns (address,uint){
require(i<baddress.length);
return (baddress[i],bmoneycount[baddress[i]]);
}
function getC(uint i) public constant returns (address,uint){
require(i<caddress.length);
return (caddress[i],cmoneycount[caddress[i]]);
}
function clearData() public returns (bool) {
require(msg.sender==owner);
aaddress.length = 0;
baddress.length = 0;
caddress.length = 0;
return true;
}
}