4일차 *** 상점 *** (4)
Console Programming/C# Console 2019. 9. 23. 11:45
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Syntax07
{
class Program
{
static void Main(string[] args)
{
//step1
//Console.WriteLine("*** 상점 ***");
//Console.WriteLine("[장검, 단검, 활, 도끼]");
//Console.WriteLine();
//Console.WriteLine("상점에서 구입 하고자 하는 아이템을 입력해주세요.");
//step2
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;
while (true)
{
Console.WriteLine("*** 상점 ***");
Console.WriteLine("[장검, 단검, 활, 도끼]");
Console.WriteLine("---------------------------");
Console.WriteLine($"금화 : {goldNow}");
Console.WriteLine("---------------------------");
Console.WriteLine("1. 장검 : 800");
Console.WriteLine("2. 단검 : 550");
Console.WriteLine("3. 활 : 760");
Console.WriteLine("4. 도끼 : 810");
Console.Write("상점에서 구입 하고자 하는 아이템을 입력해주세요. ");
string input = Console.ReadLine();
if (goldNow < priceLongSword || goldNow < priceShortSword || goldNow < priceBow || goldNow < priceAxe)
{
Console.Clear();
Console.WriteLine("금화가 부족합니다.");
Console.WriteLine();
Console.WriteLine($"금화 : {goldNow}");
Console.WriteLine("---------------------------");
Console.WriteLine("구매목록");
Console.WriteLine($"장검 x {countLongSword}");
Console.WriteLine($"단검 x {countShortSword}");
Console.WriteLine($"활 x {countBow}");
Console.WriteLine($"도끼 x {countAxe}");
Console.WriteLine();
}
else
{
if (input == "장검")
{
Console.Clear();
goldNow = goldNow - priceLongSword;
countLongSword++;
Console.WriteLine("---------------------------");
Console.WriteLine($"{input}을 구매했습니다.({-priceLongSword})");
Console.WriteLine($"금화 : {goldNow}");
Console.WriteLine("---------------------------");
Console.WriteLine("구매목록");
Console.WriteLine($"장검 x {countLongSword}");
Console.WriteLine($"단검 x {countShortSword}");
Console.WriteLine($"활 x {countBow}");
Console.WriteLine($"도끼 x {countAxe}");
Console.WriteLine();
}
else if (input == "단검")
{
Console.Clear();
goldNow = goldNow - priceShortSword;
countShortSword++;
Console.WriteLine("---------------------------");
Console.WriteLine($"{input}을 구매했습니다.({-priceShortSword})");
Console.WriteLine($"금화 : {goldNow}");
Console.WriteLine("---------------------------");
Console.WriteLine("구매목록");
Console.WriteLine($"장검 x {countLongSword}");
Console.WriteLine($"단검 x {countShortSword}");
Console.WriteLine($"활 x {countBow}");
Console.WriteLine($"도끼 x {countAxe}");
Console.WriteLine("---------------------------");
Console.WriteLine();
}
else if (input == "활")
{
Console.Clear();
goldNow = goldNow - priceBow;
countBow++;
Console.WriteLine("---------------------------");
Console.WriteLine($"{input}을 구매했습니다.({-priceBow})");
Console.WriteLine($"금화 : {goldNow}");
Console.WriteLine("---------------------------");
Console.WriteLine("구매목록");
Console.WriteLine($"장검 x {countLongSword}");
Console.WriteLine($"단검 x {countShortSword}");
Console.WriteLine($"활 x {countBow}");
Console.WriteLine($"도끼 x {countAxe}");
Console.WriteLine("---------------------------");
Console.WriteLine();
}
else if (input == "도끼")
{
Console.Clear();
goldNow = goldNow - priceAxe;
countAxe++;
Console.WriteLine("---------------------------");
Console.WriteLine($"{input}을 구매했습니다.({-priceAxe})");
Console.WriteLine($"금화 : {goldNow}");
Console.WriteLine("---------------------------");
Console.WriteLine("구매목록");
Console.WriteLine($"장검 x {countLongSword}");
Console.WriteLine($"단검 x {countShortSword}");
Console.WriteLine($"활 x {countBow}");
Console.WriteLine($"도끼 x {countAxe}");
Console.WriteLine("---------------------------");
Console.WriteLine();
}
else
{
Console.Clear();
Console.WriteLine($"해당상품 (\"{input}\")는 없습니다.");
Console.WriteLine();
}
}
}
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
'Console Programming > C# Console' 카테고리의 다른 글
4일차 *** 상점 *** (6, 7) 구매 개수 선택하기, 재고가 있는 상품 (0) | 2019.09.23 |
---|---|
4일차 *** 상점 *** (5) 구매,판매 선택하기 (0) | 2019.09.23 |
4일차 *** 상점 *** (3) (0) | 2019.09.23 |
4일차 *** 상점 *** (2) (0) | 2019.09.23 |
4일차 *** 상점 *** (0) | 2019.09.23 |