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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
Console.WriteLine("2020-04-08\n");
// 아이템, 착용, 해제, 버리기, 줍기
Console.WriteLine("아이템명 : 장검 \n");
Console.WriteLine("\"아이템명 착용\", \"아이템명 해제\", \"아이템명 주워\", \"아이템명 버려\"\n");
//착용 여부
bool equipItem = false;
//소지 여부
bool getItem = false;
for (; ; )
{
Console.Write("명령어를 입력해주세요 ");
string input = Console.ReadLine();
string item = itemArr[0];
string act = itemArr[1];
if (getItem == false)
{
switch (act)
{
case "착용":
{
Console.WriteLine("{0}할 {1}이 없습니다.", act, item);
Console.WriteLine();
}
break;
case "해제":
{
Console.WriteLine("{0}할 {1}이 없습니다.", act, item);
Console.WriteLine();
}
break;
case "버려":
{
Console.WriteLine("{0}야할 {1}이 없습니다.", act, item);
Console.WriteLine();
}
break;
case "주워":
{
Console.WriteLine("{0}을 얻었습니다.", item);
Console.WriteLine();
getItem = true;
}
break;
}
}
else
{
switch (act)
{
case "착용":
{
if (equipItem == false)
{
Console.WriteLine("{0}을 {1}했습니다.", item, act);
equipItem = true;
}
else
{
Console.WriteLine("이미 {0}은 {1} 되었습니다.", item, act);
}
Console.WriteLine();
}
break;
case "해제":
{
if (equipItem == false)
{
Console.WriteLine("{0}을 {1}할 수 없습니다.", item, act);
}
else
{
Console.WriteLine("{0}을 {1}했습니다.", item, act);
equipItem = false;
}
Console.WriteLine();
}
break;
case "버려":
{
Console.WriteLine("{0}을 버렸습니다.", item);
equipItem = false;
getItem = false;
}
Console.WriteLine();
break;
case "주워":
{
Console.WriteLine("이미 {0}을 가지고 있습니다.", item);
}
Console.WriteLine();
break;
}
}
}
|
'C# > 수업내용' 카테고리의 다른 글
2020.04.09. 수업내용 - 물약 먹기(enum, switch) (0) | 2020.04.09 |
---|---|
2020.04.09. 수업내용 - 요일 영어로 출력하기(enum,switch) (0) | 2020.04.09 |
2020.04.09. 수업내용 - 아이템 확률적으로 강화하기(열거형, Switch) (0) | 2020.04.09 |
2020.04.08. 수업내용 - 문자열을 열거형으로 변환하기 (string to enum) (0) | 2020.04.08 |
2020.04.08. 수업내용 - 열거형 변환 (캐스팅 ( ) ) (0) | 2020.04.08 |