남영운 :: 글자색 바꿔서 표현(19.09.20)

글자색 바꿔서 표현(19.09.20)

Console(콘솔)/실습 2019. 9. 20. 14:00
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax03
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("캐릭터의 이름을 입력해주세요. ");
            string characterName = Console.ReadLine();
            Console.Write("직업을 설정해주세요. ");
            string className = Console.ReadLine();
            Console.Write("전체체력을 설정해주세요. ");
            string maxHp = Console.ReadLine();
            int a = int.Parse(maxHp);
            Console.Write("공격력을 설정해주세요. ");
            string heroDamage = Console.ReadLine();
            int b = int.Parse(heroDamage);
            Console.WriteLine("------------------------------");
            Console.WriteLine("이름 : " + characterName);
            Console.WriteLine("직업 : " + className);
            Console.WriteLine("체력 : " + a + "/" + a);
            Console.WriteLine("공격력 : " + b);
            Console.WriteLine("------------------------------");
            Console.WriteLine("[step4]글자색 바꾸기");
            for (int c = 3; c <= a; c += 3)
            {
                Console.ForegroundColor=ConsoleColor.Red;
                Console.Write("몬스터에게 공격" + "(" + 3 + ")" + "을 받았습니다.");
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine(a - c + "/" + a);
            }
        }
    }
}
 
 
 

단어의 첫글자는 무조건 대문자로!!!

: