8일차 WOW 진영, 종족, 직업 선택 Enum type활용

Console Programming/C# Console 2019. 10. 1. 08:56
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax23
{
    class Program
    {
        enum camp { Alliance, Horde, None };
        enum race { Human, Dwarf, Orc, Undead, None };
        enum classes { Warlock, Priest, Monk, Hunter, DeathKnight, Warrior, Mage, Rogue, None };       
      
        static void Main(string[] args)
        {
            camp selectedCamp = camp.None;
            race selectedRace = race.None;
            classes selectedClass = classes.None;
 
            string strRace = null;
            string strClasses = null;
            Console.Write("[얼라이언스, 호드] 진영을 선택해 주세요. ");
            string strCamp = Console.ReadLine();
            switch(strCamp)
            {
                case "얼라이언스":
                    {
                        selectedCamp = camp.Alliance;
                        Console.Write("[인간, 드워프] 종족을 선택해주세요.");
                        strRace = Console.ReadLine();
 
                        switch(strRace)
                        {
                            case "인간":
                                {
                                    selectedRace = race.Human;
 
                                    Console.Write("[흑마법사, 사제] 종족을 선택해주세요.");
                                    strClasses = Console.ReadLine();
                                    switch(strClasses)
                                    {
                                        case "흑마법사":
                                            {
                                                selectedClass = classes.Warlock;
                                                break;
                                            }
                                        case "사제":
                                            {
                                                selectedClass = classes.Priest;
                                                break;
                                            }
                                    }
                                    break;
                                }
 
                            case "드워프":
                                {
                                    selectedRace = race.Dwarf;
                                    Console.Write("[수도사, 사냥꾼] 종족을 선택해주세요.");
                                    strRace = Console.ReadLine();
                                    switch (strClasses)
                                    {
                                        case "수도사":
                                            {
                                                selectedClass = classes.Monk;
                                                break;
                                            }
                                        case "사냥꾼":
                                            {
                                                selectedClass = classes.Hunter;
                                                break;
                                            }
                                    }
                                    break;
                                }
                        }
                        break;
                    }
                case "호드":
                    {
                        selectedCamp = camp.Horde;
                        Console.Write("[오크, 언데드] 종족을 선택해주세요.");
                        strRace = Console.ReadLine();
 
                        switch (strRace)
                        {
                            case "오크":
                                {
                                    selectedRace = race.Orc;
 
                                    Console.Write("[죽음의기사, 전사] 종족을 선택해주세요.");
                                    strClasses = Console.ReadLine();
                                    switch (strClasses)
                                    {
                                        case "죽음의기사":
                                            {
                                                selectedClass = classes.DeathKnight;
                                                break;
                                            }
                                        case "전사":
                                            {
                                                selectedClass = classes.Warrior;
                                                break;
                                            }
                                    }
                                    break;
                                }
 
                            case "언데드":
                                {
                                    selectedRace = race.Undead;
                                    Console.Write("[마법사, 도적] 종족을 선택해주세요.");
                                    strRace = Console.ReadLine();
                                    switch (strClasses)
                                    {
                                        case "마법사":
                                            {
                                                selectedClass = classes.Mage;
                                                break;
                                            }
                                        case "도적":
                                            {
                                                selectedClass = classes.Rogue;
                                                break;
                                            }
                                    }
                                    break;
                                }
                        }
                        break;
                    }
            }
            Console.WriteLine($"{selectedCamp}, {selectedRace}, {selectedClass} 입니다.");
            }
        }
    }
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 Enum type의 활용,

마지막 출력라인은 enum의 집합에서 바로 출력되도록 만들었다.

 

: