ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 반복문 연습 3
    C#/수업내용 2021. 3. 9. 18:10
    using System;
    
    namespace Study00
    {
        class Program
        {
            static void Main(string[] args)
            {
                //미네랄 : 90
                //가스 : 200
                //SCV가 생성되었습니다.
                //인구수 : 1/10
                //서플라이디폿 정보
                //필요 미네랄 : 100
                //SCV가 서플라이디폿을 건설을 시도 합니다.
                //미네랄이 부족합니다.
                //SCV가 미네랄을 캤습니다. +8
                //미네랄 : 98
                //SCV가 미네랄을 캤습니다. +8
                //미네랄 : 106
                //SCV가 서플라이디폿을 건설을 시도 합니다.
                //미네랄 : 6
                //SCV가 서플라이디폿을 건설합니다. 5%
                //SCV가 서플라이디폿을 건설합니다. 10%
                //....
                //SCV가 서플라이디폿을 건설합니다. 100%
                //서플라이 디폿이 완성 되었습니다.
                //인구수: 1/18
                            
                const int POPULATION_INCREASE = 8;            
                const int MINERAL_INCREASE = 8;            
                const int SUPPLY_DEPOT_MINERAL = 100;
                int mineral = 90;
                int gas = 200;
                int maxPopulation = 10;
                int currentPopulation = 1;
    
                Console.WriteLine("미네랄 : {0}", mineral);
                Console.WriteLine("가스 : {0}", gas);
                Console.WriteLine("SCV가 생성되었습니다.");
                Console.WriteLine("인구수 : {0}/{1}", currentPopulation, maxPopulation);
                Console.WriteLine("서플라이디폿 정보");
                Console.WriteLine("필요 미네랄 : {0}", SUPPLY_DEPOT_MINERAL);
                while(mineral< SUPPLY_DEPOT_MINERAL)
                {                
                    Console.WriteLine("SCV가 서플라이디폿을 건설을 시도 합니다.");
                    Console.WriteLine("미네랄이 부족합니다.");
                    Console.WriteLine("SCV가 미네랄을 캤습니다. +{0}", MINERAL_INCREASE);
                    mineral += MINERAL_INCREASE;
                    Console.WriteLine("미네랄 : {0}", mineral);
                }
                Console.WriteLine("SCV가 서플라이디폿을 건설을 시도 합니다.");
                mineral -= SUPPLY_DEPOT_MINERAL;
                Console.WriteLine("미네랄 : {0}", mineral);
                for(int progressRate = 5; progressRate <= 100; progressRate += 5)
                {
                    Console.WriteLine("SCV가 서플라이디폿을 건설합니다. {0}%", progressRate);
                }
                Console.WriteLine("서플라이 디폿이 완성 되었습니다.");
                maxPopulation += POPULATION_INCREASE;
                Console.WriteLine("인구수 : {0}/{1}", currentPopulation, maxPopulation);
            }
    
        }
    }
    

    'C# > 수업내용' 카테고리의 다른 글

    반복문 연습 4  (0) 2021.03.10
    03/09 수업 내용 메모  (0) 2021.03.10
    반복문 연습 2  (0) 2021.03.09
    반복문 연습 1  (0) 2021.03.09
    for문 연습  (0) 2021.03.09
Designed by Tistory.