C#프로그래밍

스타크래프트

다모아 2023. 7. 19. 18:12
using System;
using System.ComponentModel;

namespace HelloWorld
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string teran = "Marine";
            int maxTeranHp = 40;
            int teranAtt = 6;
            int teranHp;

            string zerg = "Zergling";
            int maxZergHp = 35;
            int zergAtt = 5;
            int zergHpRegen = 1;
            int zergHp;

            Console.WriteLine("{0}\nHit points : {1}\nGround attack : {2}\n", teran, maxTeranHp, teranAtt);
            Console.WriteLine("{0}\nHit points : {1}\nGround attack : {2}\n", zerg, maxZergHp, zergAtt);
            Console.WriteLine("{0}이 {1}을 공격 ({2}) 했습니다.", teran, zerg, teranAtt);
            zergHp = maxZergHp - teranAtt;
            string str = "";
            //str = String.Format("{0:0.00}", ((float)zergHp / maxZergHp) * 100); --> 이렇게 하면 82.86% 나옴
            Console.WriteLine("{0}이 {1}에게 피해 (-{2})을 받았습니다.({3}/{4}) {5}%\n", zerg, teran, teranAtt, zergHp, maxZergHp, Math.Truncate(((float)zergHp / maxZergHp) * 10000) / 100);
            Console.WriteLine("{0}이 {1}을 공격 ({2}) 했습니다.", zerg, teran, zergAtt);
            teranHp = maxTeranHp - zergAtt;
            str = String.Format("{0:0.00}", ((float)teranHp / maxTeranHp) * 100);
            Console.WriteLine("{0}이 {1}에게 피해 (-{2})을 받았습니다.({3}/{4}) {5}%\n", teran, zerg, zergAtt, teranHp, maxTeranHp, str);
            zergHp += zergHpRegen;
            str = String.Format("{0:0.00}", ((float)zergHp / maxZergHp) * 100);
            Console.WriteLine("{0}이 체력을 재생 (+{1}) 했습니다. ({2}/{3}) {4}%", zerg, zergHpRegen, zergHp, maxZergHp, str);
        }
    }
}

'C#프로그래밍' 카테고리의 다른 글

1일차 복습  (0) 2023.07.20
2023-07-19 과제  (0) 2023.07.20
영웅 피  (0) 2023.07.19
변환(캐스팅)  (0) 2023.07.19
디아블로 아이템 사전  (0) 2023.07.19