1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Level 11. Elevator(The Ethernaut)

Last updated at Posted at 2018-04-25

「The Ethernaut by Zeppelin Level 11. Elevator」を翻訳してみました(CryptoZombiesのように?)

原文はこちら

https://ethernaut.zeppelin.solutions
11. Elevatorをクリック

11. Elevator

難易度 4/6
このエレベーターでは、建物の最上階には到達しないぞ。右に移動?
(このレベルのクリア条件は「top」にtrueを代入(すなわち最上階に到達)することだ)

回答の助けになるヒント
  • 場合によっては、Solidityは約束(すなわち文法)を守ならいぞ。
  • この Elevatorコントラクトは、Buildingインターフェースから使用されることを想定しているぞ。

ソースコード

pragma solidity ^0.4.18;


interface Building {
  function isLastFloor(uint) view public returns (bool);
}


contract Elevator {
  bool public top;
  uint public floor;

  function goTo(uint _floor) public {
    Building building = Building(msg.sender);

    if (! building.isLastFloor(_floor)) {
      floor = _floor;
      top = building.isLastFloor(floor);
    }
  }
}
1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?