Solidity 练习001

发布时间:2024年01月07日

// SPDX-License-Identifier: DataSummer
pragma solidity >= 0.7.0 < 0.9.0;

//Variables:Variables are used to store information to be referenced and mutipule in a conputer program.

//pseudo code example code example of staring information into variables.
//store-owner = 300 - integer
//chocolate-bar = 30 -integer
//totalValue = store-owner + chocolate-bar = 310
//totalValue = 310 -integer

//learning variables and types
//three main types of variables: Booleans, Integers, Strings.

//lieDetector = boolearn to check wheterher what they say is true or false.
//walletAmount = integer that would hold the amount.
//erroMessageText = string that would say 'Error! There has been a mistake :C"

contract learnVariables{
? ? //all our solidity code goes here
? ? unit chocolateBar = 10;
? ? unit storeOwner = 300;
? ? bool lieDetecotr = true;
? ? string errorMessageText = "Error! There has been a mistake :C";
? ??
? ? unit wallet = 500;
? ? bool spend = false;
? ? string notifySpend = "you have to spend money";

}

//exercise: 1 create a new variable called wallet as an integer.
// ? ? ? ? ?2 create a boolearn called spend
// ? ? ? ? ?3 create a string give it the name notifyspend.
// ? ? ? ? ?4 initialize the wallet to 500.
// ? ? ? ? ?5 set the value of spend to false.
// ? ? ? ? ?6 add the string listral (the sring value)'you have spent money' to notifyspend.

文章来源:https://blog.csdn.net/m0_61408373/article/details/135398911
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。