3일차 케릭터의 이름을 입력해주세요. 몬스터의 공격력이 3.5
Console Programming/C# Console 2019. 9. 20. 11:31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Syntax05
{
class Program
{
static void Main(string[] args)
{
float monsterDamage = 3.5;
Console.Write("케릭터의 이름을 입력해주세요.");
string characterName = Console.ReadLine();
Console.Write("직업을 설정해주세요.");
string className = Console.ReadLine();
Console.Write("전체체력을 설정해주세요.");
float hp = maxHp;
Console.Write("공격력을 설정해주세요.");
Console.WriteLine("케릭터가 생성되었습니다.");
Console.WriteLine("--------------------------------------------");
Console.WriteLine($"이름: {characterName}");
Console.WriteLine($"직업: {className}");
Console.WriteLine($"체력: {hp}/{maxHp}");
Console.WriteLine($"공격력: {heroDamage}");
Console.WriteLine("--------------------------------------------");
Console.WriteLine("던전으로 들어갔습니다.");
for(int i = 0; i < 4; i++)
{
Console.Write($"몬스터에게 공격({monsterDamage})을 받았습니다 ");
hp = hp - monsterDamage;
Console.WriteLine($"({hp}/{maxHp})");
}
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
monsterDamage 값을 초기화 할때 3.5가 아니라 3.5f로 해야 float형 리터럴을 나타낸다.
![](https://blog.kakaocdn.net/dn/oIUK9/btqyp07Zkon/9eKnuEq1BZJt2ebjmgUolk/img.png)
'Console Programming > C# Console' 카테고리의 다른 글
$ - string interpolation (C# reference) (0) | 2019.09.20 |
---|---|
3일차 케릭터의 이름을 입력해주세요. (3) 몬스터의 데미지가 3.5이고 4번 공격함 (0) | 2019.09.20 |
3일차 케릭터의 이름을 입력해주세요. (2) 몬스터가 4번 공격함 (0) | 2019.09.20 |
3일차 케릭터의 이름을 입력해주세요. (0) | 2019.09.20 |
3일차 당신이 입력한 숫자는 "32", "23"입니다. (숫자에 큰(작은)따옴표 표시) (0) | 2019.09.20 |