This file contains hidden or 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.6.0; | |
contract DelegateProxy { | |
address internal implementation; | |
fallback() external payable { | |
address addr = implementation; | |
assembly { | |
calldatacopy(0, 0, calldatasize()) |
This file contains hidden or 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.8.0; | |
contract Charity { | |
receive() external payable { | |
// React to receiving ether | |
} | |
} |
This file contains hidden or 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
//SPDX-License-Identifier: MIT | |
pragma solidity 0.8.3; | |
contract FunctionsExample { | |
mapping(address => uint) public balanceReceived; | |
function receiveMoney() public payable { | |
assert(balanceReceived[msg.sender] + msg.value >= balanceReceived[msg.sender]); |
This file contains hidden or 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
function payMoney() public payable{ | |
amount += msg.value; | |
} |
This file contains hidden or 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
function payMoney() public payable{ | |
amount += msg.value; | |
} |
This file contains hidden or 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
//SPDX-License-Identifier: MIT | |
pragma solidity 0.8.3; | |
contract FunctionsExample { | |
mapping(address => uint) public balanceReceived; | |
address payable owner; |
This file contains hidden or 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
//SPDX-License-Identifier: MIT | |
pragma solidity 0.8.3; | |
contract FunctionsExample { | |
mapping(address => uint) public balanceReceived; | |
address payable owner; |
This file contains hidden or 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
@Test | |
void betweenLessAndManyPoints() { | |
assertEquals(49+50, pp.totalPoints(49, 5)); | |
assertEquals(50*3, pp.totalPoints(50, 5)); | |
} | |
@Test | |
void betweenLessAndManyLives() { | |
assertEquals(500*3, pp.totalPoints(500, 3)); | |
assertEquals(500+30, pp.totalPoints(500, 2)); |
This file contains hidden or 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
public class PlayerPointsTest { | |
private final PlayerPoints pp = new PlayerPoints(); | |
@Test | |
void lessPoints() { | |
assertEquals(30+50, pp.totalPoints(30, 5)); | |
} | |
@Test |
This file contains hidden or 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
public class PlayerPoints { | |
public int totalPoints(int currentPoints, int remainingLives) { | |
if(currentPoints < 50) | |
return currentPoints+50; | |
return remainingLives < 3 ? currentPoints+30 : currentPoints*3; | |
} | |
} |