상품 목록(3)
Console/실습 2019. 9. 23. 19:14
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
|
string a = "장검";
string b = "단검";
string c = "활";
string d = "도끼";
int goldNow = 5000;
int priceLongSword = 800;
int priceShortSword = 550;
int priceBow = 760;
int priceAxe = 810;
int countLongSword = 0;
int countShortSword = 0;
int countBow = 0;
int countAxe = 0;
for (int i = 0; i >= 0; i++)
{
Console.WriteLine("-------------------------------------");
Console.WriteLine("금화 : " + goldNow);
Console.WriteLine("-------------------------------------");
Console.WriteLine("상품 목록");
Console.WriteLine("-------------------------------------");
Console.WriteLine("1.장검 : " + priceLongSword);
Console.WriteLine("2.단검 : " + priceShortSword);
Console.WriteLine("3.활 : " + priceBow);
Console.WriteLine("4.도끼 : " + priceAxe);
Console.WriteLine("-------------------------------------");
Console.WriteLine("상점에서 구입하고자 하는 아이템을 입력하세요.");
string input = Console.ReadLine();
Console.WriteLine(input + "을 구매했습니다.");
Console.WriteLine("-------------------------------------");
{
if (input == a)
{
if (goldNow - priceLongSword > 0)
{
Console.Clear();
Console.WriteLine(input + "을 구매했습니다.(-" + priceLongSword + ")");
goldNow = goldNow - priceLongSword;
Console.WriteLine("금화 : " + goldNow);
}
else
{
Console.Clear();
Console.WriteLine("금화가 부족합니다");
}
}
else if (input == b)
{
if (goldNow - priceShortSword > 0)
{
Console.Clear();
Console.WriteLine(input + "을 구매했습니다.(-" + priceShortSword + ")");
goldNow = goldNow - priceShortSword;
Console.WriteLine("금화 : " + goldNow);
}
else
{
Console.Clear();
Console.WriteLine("금화가 부족합니다.");
}
}
else if (input == c)
{
if (goldNow - priceBow > 0)
{
Console.Clear();
Console.WriteLine(input + "을 구매했습니다.(-" + priceBow + ")");
goldNow = goldNow - priceBow;
Console.WriteLine("금화 : " + goldNow);
}
else
{
Console.WriteLine("금화가 부족합니다.");
}
}
else if (input == d)
{
if (goldNow - priceAxe > 0)
{
Console.Clear();
Console.WriteLine(input + "을 구매했습니다.(-" + priceAxe + ")");
goldNow = goldNow - priceAxe;
Console.WriteLine("금화 : " + goldNow);
}
else
{
Console.Clear();
Console.WriteLine("금화가 부족합니다.");
}
}
else
{
Console.WriteLine(input+"는 없는 물건입니다.");
}
Console.WriteLine("-------------------------------------");
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
