diff --git a/tutorial-01/myfirstcontract.sol b/tutorial-01/myfirstcontract.sol index a2ae8b4..4b0e997 100644 --- a/tutorial-01/myfirstcontract.sol +++ b/tutorial-01/myfirstcontract.sol @@ -1,22 +1,24 @@ -pragma solidity ^0.5.0; +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.7; + +contract myfirstcontract { -contract MyFirstContract { string private name; uint private age; - + + function setName(string memory newName) public { + name = newName; + } - + function getName() public view returns (string memory) { return name; + + } - - function setAge(uint newAge) public { - age = newAge; - } - - function getAge() public view returns (uint) { - return age; - } + + } diff --git a/tutorial-02/myfirstcontract.sol b/tutorial-02/myfirstcontract.sol index f94fce1..c40d6c8 100644 --- a/tutorial-02/myfirstcontract.sol +++ b/tutorial-02/myfirstcontract.sol @@ -1,58 +1,81 @@ -pragma solidity ^0.5.0; +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.7; interface Regulator { function checkValue(uint amount) external returns (bool); function loan() external returns (bool); } -contract Bank is Regulator { +contract Bank is Regulator{ + uint private value; - - constructor(uint amount) public { + + constructor(uint amount) { + value = amount; } - + function deposit(uint amount) public { value += amount; } - - function withdraw(uint amount) public { - if (checkValue(amount)) { + + function withdrawel(uint amount) public { + + if (checkValue(amount)){ value -= amount; + } } - + function balance() public view returns (uint) { + return value; } - - function checkValue(uint amount) public returns (bool) { - // Classic mistake in the tutorial value should be above the amount - return value >= amount; + + // Override + + function checkValue(uint amount) public override view returns (bool) { + + return value > amount; + } - - function loan() public returns (bool) { + + function loan() public override view returns (bool) { + return value > 0; + } + } -contract MyFirstContract is Bank(10) { +contract myfirstcontract is Bank(10) { + + // Opposite of Java - private String firstName; string private name; uint private age; - + + function setName(string memory newName) public { + name = newName; + } - + function getName() public view returns (string memory) { return name; + } - + function setAge(uint newAge) public { age = newAge; } - + function getAge() public view returns (uint) { return age; + } + + + }