csharp基础练习题:草蜢 - 终端游戏回合功能【难度:0级】:
终端游戏回合功能
您正在创建自己喜欢的棋盘游戏的基于文本的终端版本.在棋盘游戏,每一轮都有六个步骤必须按以下顺序发生:霸气,移动,战斗,获得金币,买更多的健康,并打印状态.
您正在使用的库(Game.Logic
在C#)已经具有以下功能.创建一个名为doTurn / DoTurn /功能do_turn
如上段所述调用以正确的顺序的功能.
- 战斗
- buyHealth
- 获得硬币
- printStatus
- 掷骰子
- 移动
- `combat`
- `buy_health`
- `get_coins`
- `print_status`
- `roll_dice`
- `move`
- `combat`
- `buy_health`
- `get_coins`
- `print_status`
- `roll_dice`
- `move`
- 战斗
- BuyHealth
- 获得硬币
- PrintStatus
- 掷骰子
- 移动
编程目标:
using static Game.Logic;
public class Kata
{
public static void DoTurn()
{
// Call functions here
}
}
测试样例:
namespace Solution
{
using static Game.Logic;
using NUnit.Framework;
using System;
[TestFixture]
public class SolutionTest
{
public void Test()
{
Kata.DoTurn();
Assert.AreEqual(6, Log.Count, "should call all 6 functions");
Assert.AreEqual("RollDice", Log[0], "should roll dice first");
Assert.AreEqual("Move", Log[1], "should move second");
Assert.AreEqual("Combat", Log[2], "should combat third");
最佳答案(多种解法):
更多关联题目:
csharp基础练习题:草蜢 - 基本功能定影液【难度:0级】–景越C# 经典编程题库,不同难度C# 练习题,适合自学C# 的新手进阶训练
csharp基础练习题:符号计数【难度:1级】–景越C# 经典编程题库,不同难度C# 练习题,适合自学C# 的新手进阶训练
免责申明
本博客所有编程题目及答案均收集自互联网,主要用于供网友学习参考,如有侵犯你的权益请联系管理员及时删除,谢谢
题目收集至https://www.codewars.com/
https://www.codewars.com/kata/grasshopper-terminal-game-turn-function