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
44
45
46
47
48
49
50
|
class App
{
enum ePortion
{
HpPortion,
MpPortion
}
public App()
{
Console.WriteLine("2020-04-09\n");
//enum, switch 물약
string heroName = "홍길동";
int maxHp = 100;
int hp = 95;
int maxMp = 100;
int mp = 85;
for(; ; )
{
Console.WriteLine("name : {0}", heroName);
Console.WriteLine("hp : {0}/{1}", hp, maxHp);
Console.WriteLine("name : {0}/{1}", mp, maxMp);
Console.WriteLine("0: 체력물약 , 1: 마나물약");
Console.Write("사용할 아이템을 입력하세요. ");
string strInput = Console.ReadLine();
int input = int.Parse(strInput);
ePortion portion = (ePortion)input;
Console.WriteLine("----------------------------");
switch(portion)
{
case ePortion.HpPortion:
Console.WriteLine("체력물약을 사용했습니다.");
hp++;
break;
case ePortion.MpPortion:
Console.WriteLine("마나물약을 사용했습니다.");
mp++;
break;
}
}
}
}
|
'C# > 수업내용' 카테고리의 다른 글
2020.04.13. 수업내용 - Barracks, Unit class(enum) (0) | 2020.04.13 |
---|---|
2020.04.13. 수업내용 - SiegeTank 클래스(enum), Factory 클래스 (0) | 2020.04.13 |
2020.04.09. 수업내용 - 요일 영어로 출력하기(enum,switch) (0) | 2020.04.09 |
2020.04.09. 수업내용 - 아이템 착용, 해제 (if, switch) (0) | 2020.04.09 |
2020.04.09. 수업내용 - 아이템 확률적으로 강화하기(열거형, Switch) (0) | 2020.04.09 |