Skip to content

Instantly share code, notes, and snippets.

View bartubozkurt's full-sized avatar
🎯
Focusing

Bartu Bozkurt bartubozkurt

🎯
Focusing
View GitHub Profile
pragma solidity ^0.6.0;
contract DelegateProxy {
address internal implementation;
fallback() external payable {
address addr = implementation;
assembly {
calldatacopy(0, 0, calldatasize())
pragma solidity ^0.8.0;
contract Charity {
receive() external payable {
// React to receiving ether
}
}
//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]);
function payMoney() public payable{
amount += msg.value;
}
function payMoney() public payable{
amount += msg.value;
}
//SPDX-License-Identifier: MIT
pragma solidity 0.8.3;
contract FunctionsExample {
mapping(address => uint) public balanceReceived;
address payable owner;
@bartubozkurt
bartubozkurt / view.sol
Created April 22, 2022 15:00
View Function | Let's make our owner-variable private and instead add a simple getter function function
//SPDX-License-Identifier: MIT
pragma solidity 0.8.3;
contract FunctionsExample {
mapping(address => uint) public balanceReceived;
address payable owner;
@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));
public class PlayerPointsTest {
private final PlayerPoints pp = new PlayerPoints();
@Test
void lessPoints() {
assertEquals(30+50, pp.totalPoints(30, 5));
}
@Test
public class PlayerPoints {
public int totalPoints(int currentPoints, int remainingLives) {
if(currentPoints < 50)
return currentPoints+50;
return remainingLives < 3 ? currentPoints+30 : currentPoints*3;
}
}