作为比特学位学习扎实课程的一部分。我被要求做以下工作:
2.创建一个名为increaseCounter的新函数,每当调用计数器时,它将使计数器的值增加10。
我已经尝试了很多事情来命名,但有这么多的问题,如果有人能帮我解决这个问题,我会非常感激,这是如此基本,但出于某种原因,没有什么工作:这是当前的代码
pragma solidity ^0.4.16;
contract FunctionTest {
bool public foo = true;
string public name;
uint256 public counter = 0;
function setName() public {
//
}
function writeToStorage() {
foo = !foo;
}
function readFromStorageConstant() public constant returns (bool) {
return foo;
}
function readFromStorageView() public view returns (bool) {
return foo;
}}
发布于 2018-01-31 09:33:49
由于某些原因,它需要将变量“name”初始化为字符串,以使其提交。
pragma solidity ^0.4.16;
contract FunctionTest {
bool public foo = true;
string public name="ChuckNorris";
uint256 public counter = 0;
function setName(string _name) public {
name = _name;
}
function increaseCounter() public {
counter += 10;
}
function writeToStorage() {
foo = !foo;
}
function readFromStorageConstant() public constant returns (bool) {
return foo;
}
function readFromStorageView() public view returns (bool) {
return foo;
}
}发布于 2018-06-22 19:49:39
确保你正在回答问题的两个部分。由于某些原因,在本课中,setName()函数在完成increaseCounter() function.Here之前不会显示您已经正确地完成了它,这是帮助我提升到下一个级别的解决方案。
pragma solidity ^0.4.16;
contract FunctionTest {
bool public foo = true;
string public name;
uint256 public counter = 0;
function setName(string _name) public {
name = _name;
}
function increaseCounter() public {
counter += 10;
}
function writeToStorage() {
foo = !foo;
}
function readFromStorageConstant() public constant returns (bool) {
return foo;
}
function readFromStorageView() public view returns (bool) {
return foo;
}
funciton increaseCounter() {
counter += 10; }
}发布于 2018-01-21 01:54:07
应该很直截了当。
pragma solidity ^0.4.16;
contract FunctionTest {
bool public foo = true;
string public name;
uint256 public counter = 0;
function setName(string _name) public {
name = _name;
}
function increaseCounter() public {
counter += 10;
}
function writeToStorage() {
foo = !foo;
}
function readFromStorageConstant() public constant returns (bool) {
return foo;
}
function readFromStorageView() public view returns (bool) {
return foo;
}
}https://stackoverflow.com/questions/48362797
复制相似问题