Skip to content

Commit

Permalink
make Lecture02 readme source code comments japanese and some modifica…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
PolymetisOutis committed Jul 28, 2024
1 parent f53e0cc commit 9cb73fd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 34 deletions.
18 changes: 9 additions & 9 deletions Languages/ja/02_ValueTypes_ja/ValueTypes.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;
contract ValueTypes{
// Boolean(論理型
// Boolean(真偽値型
bool public _bool = true;
// Boolean operators(論理演算子)
bool public _bool1 = !_bool; // logical NOT
bool public _bool2 = _bool && _bool1; // logical AND
bool public _bool3 = _bool || _bool1; // logical OR
bool public _bool4 = _bool == _bool1; // equality
bool public _bool5 = _bool != _bool1; // inequality
bool public _bool1 = !_bool; // logical NOT     (否定)
bool public _bool2 = _bool && _bool1; // logical AND(論理積)
bool public _bool3 = _bool || _bool1; // logical OR (論理和)
bool public _bool4 = _bool == _bool1; // equality (等価)
bool public _bool5 = _bool != _bool1; // inequality(不等価)


// Integer(整数型)
Expand All @@ -17,9 +17,9 @@ contract ValueTypes{
uint256 public _number = 20220330;
// Integer operators(整数型の演算子)
uint256 public _number1 = _number + 1; // +,-,*,/
uint256 public _number2 = 2**2; // exponent
uint256 public _number3 = 7 % 2; // modulo (modulus)
bool public _numberbool = _number2 > _number3; // greater than
uint256 public _number2 = 2**2; // exponent     (べき乗)
uint256 public _number3 = 7 % 2; // modulo (modulus)(剰余(モジュロ))
bool public _numberbool = _number2 > _number3; // greater than(大なり)


// Address data type(アドレス型)
Expand Down
51 changes: 26 additions & 25 deletions Languages/ja/02_ValueTypes_ja/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Booleanはバイナリ変数で、その値は`true``false`です。

```solidity
// Boolean
// Boolean(真偽値型)
bool public _bool = true;
```

Expand All @@ -44,12 +44,12 @@ Boolean型の演算子には次のものがあります:
ソースコード:

```solidity
// Boolean operators
bool public _bool1 = !_bool; // logical NOT
bool public _bool2 = _bool && _bool1; // logical AND
bool public _bool3 = _bool || _bool1; // logical OR
bool public _bool4 = _bool == _bool1; // equality
bool public _bool5 = _bool != _bool1; // inequality
// Boolean operators(論理演算子)
bool public _bool1 = !_bool; // logical NOT(否定)
bool public _bool2 = _bool && _bool1; // logical AND(論理積)
bool public _bool3 = _bool || _bool1; // logical OR (論理和)
bool public _bool4 = _bool == _bool1; // equality (等価)
bool public _bool5 = _bool != _bool1; // inequality (不等価)
```

上記のソースコードより: 変数`_bool`の値は`true`; `_bool1``_bool`じゃないので、`false`となる; `_bool && _bool1``false`; `_bool || _bool1``true`; `_bool == _bool1``false`; そして`_bool != _bool1``true`となります。
Expand All @@ -60,10 +60,10 @@ Boolean型の演算子には次のものがあります:
SolidityのInteger型には符号付き整数`int`と符号なし整数`uint`があります。 最大256ビット型の整数やデータユニットを格納出来ます。

```solidity
// Integer
int public _int = -1; // integers including negative numbers
uint public _uint = 1; // non-negative numbers
uint256 public _number = 20220330; // 256-bit positive integers
// Integer(整数型)
int public _int = -1; // integers including negative numbers(負の数を含む整数型)
uint public _uint = 1; // non-negative numbers(非負の数)
uint256 public _number = 20220330; // 256-bit positive integers(256ビットの正の数)
```
よく使われる整数向け演算子には次のものがあります:

Expand All @@ -74,11 +74,11 @@ SolidityのInteger型には符号付き整数`int`と符号なし整数`uint`が
ソースコード:

```solidity
// Integer operations
// Integer operations(整数演算)
uint256 public _number1 = _number + 1; // +, -, *, /
uint256 public _number2 = 2**2; // Exponent
uint256 public _number3 = 7 % 2; // Modulo (Modulus)
bool public _numberbool = _number2 > _number3; // Great than
uint256 public _number2 = 2**2; // Exponent (べき乗)
uint256 public _number3 = 7 % 2; // Modulo (Modulus)(剰余(モジュロ))
bool public _numberbool = _number2 > _number3; // Great than(大なり)
```

上記のソースコードを実行し、各変数の値をチェックすることが出来ます。
Expand All @@ -94,25 +94,26 @@ SolidityのInteger型には符号付き整数`int`と符号なし整数`uint`が
ソースコード:

```solidity
// Address
// Address(アドレス型)
address public _address = 0x7A58c0Be72BE218B41C608b7Fe7C5bB630736C71;
address payable public _address1 = payable(_address); // payable address (can transfer fund and check balance)
// Members of address
uint256 public balance = _address1.balance; // balance of address
//(ペイアブルなアドレス(資金の移動と残高の確認が可能))
// Members of address(アドレスのメンバ)
uint256 public balance = _address1.balance; // balance of address(アドレスの残高)
```

### 4. Fixed-size byte arrays(固定サイズのバイト配列型
### 4. Fixed-size byte arrays(固定サイズのバイト配列(固定長配列)型

Solidityのバイト配列には2つの種類があります:

- 固定長のバイト配列: それぞれの要素のサイズ(最大32バイト)によって`byte``bytes8`, `bytes32`などを含む値型に属しています。配列の長さは宣言された後で変更されることは出来ません。
- 固定長のバイト配列(固定長配列): それぞれの要素のサイズ(最大32バイト)によって`byte``bytes8`, `bytes32`などを含む値型に属しています。配列の長さは宣言された後で変更されることは出来ません。

- 可変長バイト配列: `bytes`などを含み、参照型に属しています。配列の長さは宣言された後で変更することが可能です。後の章で詳しく学んでいきます。
- 可変長バイト配列(可変長配列): `bytes`などを含み、参照型に属しています。配列の長さは宣言された後で変更することが可能です。後の章で詳しく学んでいきます。

ソースコード:

```solidity
// Fixed-size byte arrays
// Fixed-size byte arrays(固定長配列)
bytes32 public _byte32 = "MiniSolidity";
bytes1 public _byte = _byte32[0];
```
Expand All @@ -128,16 +129,16 @@ Solidityのバイト配列には2つの種類があります:
ソースコード:

```solidity
// Let uint 0, 1, 2 represent Buy, Hold, Sell
// Let uint 0, 1, 2 represent Buy, Hold, Sell(uint型の0,1,2がBuy,Hold,Sellを表すとする)
enum ActionSet { Buy, Hold, Sell }
// Create an enum variable called action
// Create an enum variable called action(actionという列挙型変数を作成)
ActionSet action = ActionSet.Buy;
```

`uint`に容易に変換出来ます。

```solidity
// Enum can be converted into uint
// Enum can be converted into uint(列挙型はuint型に変換出来る)
function enumToUint() external view returns(uint){
return uint(action);
}
Expand Down

0 comments on commit 9cb73fd

Please sign in to comment.