15 步:让我们继续存储和返回damage ,直到我们可以在所有功能之外使用它。

  • 查看cast_spell()内部,找到fireball()rock_smash()函数调用
  • 两个函数调用前添加一个返回变量来存储返回值,如下所示: damage =

此时, damage值已经从calculate_damage()fireball()rock_smash()并且现在在cast_spell()中!如果我们再退回一次,我们可以在MAIN CODE部分使用damage

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • 提交作品
  • 下个活动
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)