using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace hello_world
{
class Program
{
static void Main(string[] args)
{
Console.Write("명령어를 입력하세요 (늑대 쳐): ");
string input = Console.ReadLine();
switch (input)
{
case "늑대 쳐":
Console.WriteLine("몇회 공격 하시겠습니까? (1~5): ");
int input_count = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < input_count; i++)
{
if (input_count < 1)
{
Console.WriteLine("공격횟수는 0보다 커야합니다.");
break;
}
else
{
Console.WriteLine("늑대를 공격했습니다.");
}
}
break;
default:
Console.WriteLine("그런 명령어는 없습니다.");
return;
}
}
}
}

'C# > 수업 내용' 카테고리의 다른 글
| [C#] Method (0) | 2021.08.24 |
|---|---|
| [C#] 2021-08-24 오전 (0) | 2021.08.24 |
| [C#] switch case문 (0) | 2021.08.23 |
| [C#] 2021-8-20 challenge 문제, Random 중복값 방지 (0) | 2021.08.20 |
| [C#] 2021-08-20 오후 for문 연습 문제 11~17, challenge (0) | 2021.08.20 |