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: GPL-3.0 | |
| pragma solidity >=0.7.0 <0.9.0; | |
| /// @title Voting with delegation. | |
| contract Ballot { | |
| // This declares a new complex type which will | |
| // be used for variables later. | |
| // It will represent a single voter. | |
| struct Voter { | |
| uint weight; // weight is accumulated by delegation | |
| bool voted; // if true, that person already voted |
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.0; | |
| contract Counter { | |
| uint public count; | |
| function increment() external { | |
| count += 1; | |
| } | |
| } |
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.0; | |
| abstract contract Animal { | |
| string name; | |
| constructor (string memory n){ | |
| name = n; | |
| } |
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.0; | |
| contract Bank { | |
| uint depositAmount = 0; | |
| address payable receiver; | |
| address owner; | |
| event logDepositAmount(uint); | |
| constructor(){ |
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.0; | |
| import "@openzeppelin/contracts/utils/Strings.sol"; | |
| contract School { | |
| address owner; | |
| constructor() public{ | |
| owner = 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
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.0; | |
| contract RandomPractise{ | |
| } |
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
| var $vat = 20; | |
| var $vat_divisor = 1 + ($vat/100); | |
| var $price_gross = 5; | |
| var $price_net = ($price_gross/$vat_divisor).toFixed(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
| <?php | |
| // get net price | |
| $vat = 20; | |
| $vat_divisor = 1 + ($vat/100); | |
| $price_gross = 5; | |
| $price_net = number_format($price_gross/$vat_divisor,2); | |
| //Adding VAT to the price of a product | |
| //The VAT rate / percentage. | |
| $vat = 20; |
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 for existence of nested JavaScript object key | |
| function checkNested(obj) { | |
| var args = Array.prototype.slice.call(arguments, 1); | |
| for (var i = 0; i < args.length; i++) { | |
| if (!obj || !obj.hasOwnProperty(args[i])) { | |
| return false; | |
| } | |
| obj = obj[args[i]]; | |
| } |
NewerOlder