Skip to content

Commit

Permalink
first homework
Browse files Browse the repository at this point in the history
  • Loading branch information
seanxwzhang committed Jan 9, 2018
1 parent e4e5383 commit 901d828
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion lesson1/assignment/yours.sol
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;
}
}

0 comments on commit 901d828

Please sign in to comment.