Skip to content

Made tutorial 2 work with the Solidity ^0.7.0 version #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 14 additions & 20 deletions tutorial-02/myfirstcontract.sol
Original file line number Diff line number Diff line change
@@ -1,57 +1,51 @@
pragma solidity ^0.5.0;
pragma solidity ^0.7.0;

interface Regulator {
interface Regulator{
function checkValue(uint amount) external returns (bool);
function loan() external returns (bool);
}

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)) {
value -= amount;
value -= amount;
}
}

function balance() public view returns (uint) {
return value;
}

function checkValue(uint amount) public returns (bool) {
function checkValue(uint amount) override view public returns (bool) {
// Classic mistake in the tutorial value should be above the amount
return value >= amount;
}

function loan() public returns (bool) {
function loan() override view public returns (bool) {
return value > 0;
}
}

contract MyFirstContract is Bank(10) {
// Tutorial 01
contract myFirstContract is Bank(10) {

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 getName() public view returns (string memory) {
return name;
}
function getAge() public view returns (uint) {
return age;
}
Expand Down