스타크래프트
2023. 7. 19.

using System;
using System.ComponentModel;
using System.Xml.Linq;

namespace HelloWorld
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string characterName = "Marine";
            int hitPoint1 = 40;
            int groundAttack1 = 6;

            string characterName2 = "Zergling";
            int hitPoint2 = 35;
            int groundAttack2 = 5;

            int last1 = hitPoint2 - groundAttack1;
            float percentage = ((float)last1 / (float)hitPoint2)*100;

            Console.WriteLine("{0}이 {1}을 공격 ({2})했습니다.",characterName,characterName2,groundAttack1);
            Console.WriteLine("{0}이 {1}에게 피해 (-{2})을 받았습니다. ({3}/{4}) {5:0.00}%",characterName2,characterName,groundAttack1,last1,hitPoint2,percentage);

            int last2 = hitPoint1 - groundAttack2;
            percentage = ((float)last2 / (float)hitPoint1) * 100;

            Console.WriteLine("\n");
            Console.WriteLine("{0}이 {1}을 공격 ({2})했습니다.", characterName2, characterName, groundAttack2);
            Console.WriteLine("{0}이 {1}에게 피해 (-{2})을 받았습니다. ({3}/{4}) {5:0.00}%", characterName, characterName2, groundAttack2, last2, hitPoint1, percentage);
            int recovery = 1;
            last1 = last1 + recovery;
            percentage = ((float)last1 / (float)hitPoint2) * 100;
            Console.WriteLine("\n");
            Console.WriteLine("{0}이 체력을 재생 (+{1})했습니다.({2}/{3}) {4:0.00}%",characterName2,recovery,last1,hitPoint2,percentage);
        }
    }
}

'C# 기초' 카테고리의 다른 글

input, enum의 활용, 값 형식,참조 형식, Boxing,산술연산  (0) 2023.07.20
var, const, 열거형  (0) 2023.07.20
캐스팅  (0) 2023.07.19
디아블로 아이템 사전  (0) 2023.07.19
Hand Axe  (0) 2023.07.19
myoskin