9일차 메서드의 정의(16) 인벤토리, 아이템줍기
Console Programming/C# Console 2019. 10. 3. 15:35장검, 단검, 체력물약, 가죽옷
가방에 넣을 아이템을 선택해주세요. 장검
소지품: 장검
단검, 체력물약, 가죽옷
가방에 넣을 아이템을 선택해주세요. 체력물약
소지품: 장검, 체력물약
단검, 가죽옷
가방에 넣을 아이템을 선택해주세요. 가죽옷
소지품: 장검, 체력물약, 가죽옷
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
|
using System;
using Syntax24;
namespace Syntax24
{
class App
{
string droppedItem = "장검, 단검, 체력물약, 가죽옷";
string pickitem = "";
string inven = "";
int count = 0;
public App()
{
Console.WriteLine("2019-09-30");
Console.WriteLine();
while (true)
{
PickItem();
Console.WriteLine();
Console.Write("소지품: ");
Inventory();
}
}
public void Inventory()
{
inven = inven + pickitem;
Console.WriteLine(inven);
inven = inven + ", ";
}
public void PickItem()
{
Console.WriteLine(droppedItem);
Console.Write("가방에 넣을 아이템을 선택해주세요. ");
pickitem = Console.ReadLine();
if (pickitem == "장검")
{
droppedItem = droppedItem.Replace("장검, ", "");
if (droppedItem == "장검")
droppedItem = "";
}
else if (pickitem == "단검")
{
droppedItem = droppedItem.Replace("단검, ", "");
if (droppedItem == "단검")
droppedItem = "";
}
else if (pickitem == "체력물약")
{
droppedItem = droppedItem.Replace("체력물약, ", "");
if (droppedItem == "체력물약")
droppedItem = "";
}
else if (pickitem == "가죽옷")
{
droppedItem = droppedItem.Replace(", 가죽옷", "");
if (droppedItem == "가죽옷")
droppedItem = "";
}
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
체력물약을 소지품에서 꺼내도 없어지지 않는 문제가 있다.
'Console Programming > C# Console' 카테고리의 다른 글
10일차 클래스(2) 버거상점, 세트메뉴 (0) | 2019.10.04 |
---|---|
10일차 클래스 커맨트센터, 유닛(공격,피격) (0) | 2019.10.04 |
9일차 메서드의 정의(15) 캐릭터 선택, 몬스터 공격 (0) | 2019.10.03 |
9일차 메서드의 정의(14) 피격시 영웅의 체력을 감소 시키는 메서드 (0) | 2019.10.03 |
9일차 메서드의 정의(14) 세 수를 입력받아 두 번째 큰 수를 반환 (0) | 2019.10.03 |