forked from linjie-1/guigulive-operation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4e5383
commit 901d828
Showing
1 changed file
with
43 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,43 @@ | ||
/*作业请提交在这个目录下*/ | ||
pragma solidity ^0.4.14; | ||
|
||
contract PayRoll { | ||
uint salary = 1 ether; | ||
address frank = 0xca35b7d915458ef540ade6068dfe2f44e8fa733c; | ||
uint constant duration = 10 seconds; | ||
uint lastpayday = now; | ||
|
||
function addFund() payable returns (uint) { | ||
return this.balance; | ||
} | ||
|
||
function calculateRunway() returns (uint) { | ||
return this.balance / salary; | ||
} | ||
|
||
function hasEnoughfund() returns (bool) { | ||
return calculateRunway() > 0; | ||
} | ||
|
||
function getPaid() { | ||
if(msg.sender != frank) { | ||
revert(); | ||
} | ||
uint nextPayday = lastpayday + duration; | ||
if (nextPayday >= now) { | ||
revert(); | ||
} | ||
lastpayday = nextPayday; | ||
frank.transfer(salary); | ||
} | ||
|
||
function changeAddress() { | ||
frank = msg.sender; | ||
} | ||
|
||
function changeSalary() { | ||
if (msg.value <= 0) { | ||
revert(); | ||
} | ||
salary = msg.value; | ||
} | ||
} |