C#/수업 내용

if문 종족 선택

HSH12345 2023. 1. 2. 15:41
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Study01
{
    class Program
    {
        enum SPECIES
        {
            TERRAN,
            ZERG,
            PROTOSS
        }
        static void Main(string[] args)
        {
            Console.WriteLine("종족을 선택해주세요.(0 : Terran, 1 : Zerg, 2 : Protoss 중 선택)");

            int input;
            input = Convert.ToInt32(Console.ReadLine());
            SPECIES species;

            
            if(input == 0)
            {
                species = SPECIES.TERRAN;
                Console.WriteLine("{0}을 선택하였습니다.", species);
            }
            else if(input == 1)
            {
                species = SPECIES.ZERG;
                Console.WriteLine("{0}을 선택하였습니다.", species);
            }
            else if (input == 2)
            {
                species = SPECIES.PROTOSS;
                Console.WriteLine("{0}을 선택하였습니다.", species);
            }
            else
            {
                Console.WriteLine("숫자를 잘못입력하였습니다.");
            }
        }
    }
}