// --- 2 ---
using System;

class Program
{
    static void Main()
    {
        // 여기서 코드를 작성합니다.
    }
}

// --- 4 ---
using System;

class Program
{
    static void Main()
    {
        Console.WriteLine("Hello C#");
    }
}

// --- 6 ---
int a = 10;
int b = 20;
int c = a + b;
Console.WriteLine(c);

// --- 8 ---
int a = 10;        // 정수
int b = -20;       // 음수
float d = 0.2f;    // f 를 붙여야 합니다
double e = -3.0;

Console.WriteLine(a + b);
Console.WriteLine(d);
Console.WriteLine(e);

// --- 10 ---
int a = 7;
int b = 3;
Console.WriteLine(a / b);
Console.WriteLine(a % b);
Console.WriteLine((float)a / b);

// --- 11 ---
int money = 5000;
int apple = 800;
int count = money / apple;
Console.WriteLine("사과를 " + count + "개 살 수 있습니다.");

// --- 13 ---
char grade = 'A';
string name = "홍길동";    // 문자열은 string 하나로
Console.WriteLine(grade);
Console.WriteLine(name);

// --- 15 ---
string a = "Hello";
string b = a;            // 복사
b = b + " World";        // 이어 붙이기
if (a == "Hello") Console.WriteLine("같습니다");

// --- 17 ---
bool isJumping = false;
isJumping = true;
if (isJumping) Console.WriteLine("점프 중");

// --- 19 ---
int a = 10;
Console.WriteLine("나는 어제 " + a + "개의 사탕을 먹었습니다.");
Console.WriteLine($"나는 어제 {a}개의 사탕을 먹었습니다.");

// --- 21 ---
float avg = 86.25f;
Console.WriteLine($"평균: {avg:F2}");

// --- 23 ---
Console.Write("나이를 입력하세요: ");
int age = int.Parse(Console.ReadLine());
Console.WriteLine($"당신은 {age}살입니다.");

// --- 24 ---
Console.Write("이름을 입력하세요: ");
string name = Console.ReadLine();
Console.Write("나이를 입력하세요: ");
int age = int.Parse(Console.ReadLine());
Console.WriteLine($"안녕하세요, {name}님! 당신은 {age}살입니다.");

// --- 25 ---
Console.Write("첫 번째 정수를 입력하세요: ");
int a = int.Parse(Console.ReadLine());
Console.Write("두 번째 정수를 입력하세요: ");
int b = int.Parse(Console.ReadLine());

Console.WriteLine($"합: {a + b}");
Console.WriteLine($"차: {a - b}");
Console.WriteLine($"곱: {a * b}");
Console.WriteLine($"몫: {a / b}");
Console.WriteLine($"나머지: {a % b}");

// --- 27 ---
float f = 3.9f;
int i = (int)f;          // 3 (소수점 버림)

string s = "2021";
int year = int.Parse(s);        // 문자열 → 정수
string back = year.ToString();  // 정수 → 문자열
Console.WriteLine($"{i} / {year} / {back}");

// --- 29 ---
const int MaxHp = 100;
const float Speed = 5f;
Console.WriteLine(MaxHp);

// --- 31 ---
int money = 1000;
int candy = 200;
if (money > candy)
{
    Console.WriteLine("캔디를 살 수 있습니다.");
}
else
{
    Console.WriteLine("캔디를 살 수 없습니다.");
}

// --- 33 ---
int money = 5;
int candy = 7;
int point = 2;
if (money > candy)
    Console.WriteLine("1-캔디를 살 수 있습니다.");
else if (money == candy)
    Console.WriteLine("2-캔디를 살 수 있습니다.");
else if (point >= 2)
    Console.WriteLine("3-캔디를 살 수 있습니다.");
else
    Console.WriteLine("캔디를 살 수 없습니다.");

// --- 34 ---
Console.Write("나이를 입력하세요: ");
int age = int.Parse(Console.ReadLine());

if (age >= 20)
    Console.WriteLine("성인");
else
    Console.WriteLine("미성년자");

// --- 35 ---
Console.Write("정수 세 개를 한 줄에 하나씩 입력하세요: ");
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
int c = int.Parse(Console.ReadLine());

if (a > b && a > c)
    Console.WriteLine($"가장 큰 수는 {a}입니다.");
else if (b > a && b > c)
    Console.WriteLine($"가장 큰 수는 {b}입니다.");
else
    Console.WriteLine($"가장 큰 수는 {c}입니다.");

// --- 37 ---
int score = 3;
switch (score)
{
    case 1:
        Console.WriteLine("C등급입니다.");
        break;
    case 2:
        Console.WriteLine("B등급입니다.");
        break;
    case 3:
        Console.WriteLine("A등급입니다.");
        break;
    default:
        Console.WriteLine("등급을 매길 수 없습니다.");
        break;
}

// --- 38 ---
string command = "공격";
switch (command)
{
    case "공격":
        Console.WriteLine("칼을 휘두릅니다.");
        break;
    case "방어":
        Console.WriteLine("방패를 듭니다.");
        break;
    default:
        Console.WriteLine("알 수 없는 명령입니다.");
        break;
}

// --- 40 ---
int clear = 0;
while (clear < 5)
{
    Console.WriteLine($"현재까지 게임을 {clear}번 클리어 했습니다.");
    clear = clear + 1;
    if (clear == 5)
    {
        Console.WriteLine("레벨이 올라갑니다.");
    }
}

// --- 41 ---
int cupramen = 4;
while (true)
{
    Console.Write("돈을 넣으세요: ");
    int money = int.Parse(Console.ReadLine());

    if (money == 1500)
    {
        Console.WriteLine("컵라면을 줍니다.");
        cupramen--;
    }
    else if (money > 1500)
    {
        Console.WriteLine($"컵라면을 주고, 거스름돈 {money - 1500}원을 돌려 줍니다.");
        cupramen--;
    }
    else
    {
        Console.WriteLine("돈이 모자랍니다. 돈을 돌려줍니다.");
    }

    if (cupramen == 0)
    {
        Console.WriteLine("컵라면이 다 떨어졌습니다.");
        break;
    }
}

// --- 42 ---
Console.Write("학생수를 입력하시오: ");
int people = int.Parse(Console.ReadLine());
int count = 1;
int sum = 0;

while (count <= people)
{
    Console.Write($"{count}번 학생의 점수를 입력하세요: ");
    int num = int.Parse(Console.ReadLine());
    sum += num;
    count++;
}

Console.WriteLine($"총합계는 {sum}입니다.");
Console.WriteLine($"평균은 {(float)sum / people:F2}입니다.");

// --- 44 ---
for (int i = 0; i < 5; i++)
{
    Console.Write($"{i} ");
}

// --- 45 ---
Console.Write("정수를 입력하세요: ");
int num = int.Parse(Console.ReadLine());
int sum = 0;

for (int i = 1; i <= num; i++)
{
    sum += i;
}

Console.WriteLine($"합: {sum}");

// --- 47 ---
for (int i = 0; i < 3; i++)
{
    for (int j = 0; j < 4; j++)
    {
        Console.Write($"{j} ");
    }
    Console.WriteLine();
}

// --- 48 ---
for (int dan = 2; dan <= 5; dan++)
{
    Console.WriteLine($"=== {dan}단 ===");
    for (int num = 1; num <= 9; num++)
    {
        Console.WriteLine($"{dan} × {num} = {dan * num}");
    }
    Console.WriteLine();
}

// --- 49 ---
for (int i = 1; i <= 5; i++)
{
    // 공백 출력
    for (int j = 1; j <= 5 - i; j++)
    {
        Console.Write(" ");
    }
    // 숫자 출력
    for (int k = 1; k <= 2 * i - 1; k++)
    {
        Console.Write(k);
    }
    Console.WriteLine();
}

// --- 51 ---
// 크기만 지정 (전부 0으로 채워집니다)
int[] arr = new int[5];
// 크기와 함께 초기화
int[] arr2 = new int[5] { 1, 2, 3, 4, 5 };
// 크기 생략
int[] arr3 = { 1, 2, 3, 4, 5 };

// --- 52 ---
int[] arr = new int[5];
Console.WriteLine(arr[0]);
Console.WriteLine(arr[4]);

// --- 54 ---
int[] arr = { 10, 20, 30, 40, 50 };
Console.WriteLine(arr[0]);
Console.WriteLine(arr[4]);
arr[2] = 100;
// 배열 크기 구하기
int size = arr.Length;
Console.WriteLine($"크기: {size}");

// --- 56 ---
int[] arr = { 1, 4, 8, 9, 13 };
for (int i = 0; i < arr.Length; i++)
{
    Console.Write($"{arr[i]} ");
}

// --- 57 ---
int[] arr = { 1, 4, 8, 9, 13 };

foreach (int x in arr)
{
    Console.Write($"{x} ");
}

// --- 58 ---
int[] arr = { 34, 67, 43, 89, 55, 3, 45 };
int max = arr[0];

foreach (int x in arr)
{
    if (max < x)
    {
        max = x;
    }
}

Console.WriteLine($"가장 큰 수는 {max}입니다.");

// --- 59 ---
int[] arr = { 10, 20, 30, 40, 50 };
int sum = 0;

foreach (int x in arr)
{
    sum += x;
}

Console.WriteLine($"합: {sum}");
Console.WriteLine($"평균: {(float)sum / arr.Length:F2}");

// --- 60 ---
using System;
using System.Collections.Generic;   // List 를 쓰려면 필요합니다

class Program
{
    static void Main()
    {
        List<string> items = new List<string>();

        items.Add("포션");        // 추가
        items.Add("검");
        items.Add("방패");

        Console.WriteLine(items[0]);        // 인덱스로 접근
        Console.WriteLine(items.Count);     // 개수

        items.Remove("검");                 // 값으로 삭제
        Console.WriteLine(items.Count);

        foreach (string item in items)
        {
            Console.Write($"{item} ");
        }
    }
}

// --- 61 ---
List<string> items = new List<string>();

items.Add("포션");
items.Add("낡은 검");
items.Add("나무 방패");

items.Remove("낡은 검");

for (int i = 0; i < items.Count; i++)
{
    Console.WriteLine($"{i + 1}번 칸: {items[i]}");
}

// --- 63 ---
int[,] arr = {
    { 1, 2, 3, 4 },
    { 5, 6, 7, 8 },
    { 9, 10, 11, 12 }
};
Console.WriteLine(arr[1, 2]);   // 7

// --- 64 ---
int[,] arr = {
    { 1, 2, 3, 4 },
    { 5, 6, 7, 8 },
    { 9, 10, 11, 12 }
};

for (int i = 0; i < arr.GetLength(0); i++)
{
    for (int j = 0; j < arr.GetLength(1); j++)
    {
        Console.Write($"{arr[i, j]} ");
    }
    Console.WriteLine();
}

// --- 65 ---
int[,] scores = {
    { 85, 90, 78, 92 },
    { 88, 76, 95, 87 },
    { 92, 85, 90, 88 }
};

for (int i = 0; i < scores.GetLength(0); i++)
{
    int total = 0;
    for (int j = 0; j < scores.GetLength(1); j++)
    {
        total += scores[i, j];
    }
    Console.WriteLine($"{i + 1}번 학생 평균: {(float)total / scores.GetLength(1):F2}");
}

// --- 67 ---
string str = "Hello";
Console.WriteLine(str.Length);
Console.WriteLine(str[0]);
Console.WriteLine(str[4]);

// --- 69 ---
// C# — 아무것도 포함하지 않아도 됩니다
a.Length;             // 길이
string b = a;         // 복사
a = a + b;            // 이어 붙이기
a == b;               // 비교

// --- 70 ---
string a = "Hello World";

Console.WriteLine(a.ToUpper());            // 전부 대문자
Console.WriteLine(a.ToLower());            // 전부 소문자
Console.WriteLine(a.Contains("World"));    // 포함하고 있는가
Console.WriteLine(a.Replace("World", "C#"));  // 바꾸기
Console.WriteLine(a.Substring(6));         // 6번 자리부터 끝까지
Console.WriteLine(a.Substring(0, 5));      // 0번부터 5글자
Console.WriteLine(a.IndexOf("World"));     // 몇 번 자리에 있는가

// --- 71 ---
Console.Write("정수 세 개를 빈칸으로 띄어 입력하세요: ");
string line = Console.ReadLine();

string[] parts = line.Split(' ');   // 공백으로 자르기 → 문자열 배열

int a = int.Parse(parts[0]);
int b = int.Parse(parts[1]);
int c = int.Parse(parts[2]);

Console.WriteLine($"합: {a + b + c}");

// --- 72 ---
Console.Write("점수 다섯 개를 빈칸으로 띄어 입력하세요: ");
string[] parts = Console.ReadLine().Split(' ');

int sum = 0;
foreach (string p in parts)
{
    sum += int.Parse(p);
}

Console.WriteLine($"총점: {sum}");
Console.WriteLine($"평균: {(float)sum / parts.Length:F2}");

// --- 74 ---
string str = "Hello";

foreach (char ch in str)
{
    Console.Write($"{ch} ");
}

// --- 75 ---
string str = "Hello World";
int count = 0;

foreach (char ch in str)
{
    if (ch >= 'A' && ch <= 'Z')
    {
        count++;
    }
}

Console.WriteLine($"대문자 개수: {count}");

// --- 76 ---
string str = "Hello World";
char target = 'l';
int count = 0;

for (int i = 0; i < str.Length; i++)
{
    if (str[i] == target)
    {
        count++;
    }
}

Console.WriteLine($"'{target}' 문자가 {count}번 나타납니다.");

// --- 78 ---
string[] names = { "홍길동", "김철수", "이영희" };

for (int i = 0; i < names.Length; i++)
{
    Console.WriteLine($"{i + 1}번: {names[i]}");
}

// --- 79 ---
string[] names = new string[3];

Console.WriteLine("3명의 이름을 입력하세요.");
for (int i = 0; i < names.Length; i++)
{
    Console.Write($"{i + 1}번: ");
    names[i] = Console.ReadLine();
}

Console.WriteLine();
Console.WriteLine("입력한 이름:");
foreach (string name in names)
{
    Console.WriteLine(name);
}

// --- 81 ---
using System;

class Program
{
    static int Add(int a, int b)
    {
        return a + b;
    }

    static void Main()
    {
        int result = Add(10, 20);
        Console.WriteLine(result);
    }
}

// --- 82 ---
using System;

class Program
{
    // 형태 1: 매개변수 없고, 반환값 없음
    static void PrintHello()
    {
        Console.WriteLine("Hello!");
    }

    // 형태 2: 매개변수 없고, 반환값 있음
    static int GetNumber()
    {
        return 100;
    }

    // 형태 3: 매개변수 있고, 반환값 없음
    static void PrintSum(int a, int b)
    {
        Console.WriteLine(a + b);
    }

    // 형태 4: 매개변수 있고, 반환값 있음
    static int Add(int a, int b)
    {
        return a + b;
    }

    static void Main()
    {
        PrintHello();
        Console.WriteLine(GetNumber());
        PrintSum(40, 50);
        Console.WriteLine(Add(40, 50));
    }
}

// --- 83 ---
using System;

class Program
{
    static bool IsEven(int num)
    {
        if (num % 2 == 0)
            return true;
        else
            return false;
    }

    static void Main()
    {
        Console.Write("정수를 입력하세요: ");
        int num = int.Parse(Console.ReadLine());

        if (IsEven(num))
            Console.WriteLine("짝수입니다.");
        else
            Console.WriteLine("홀수입니다.");
    }
}

// --- 85 ---
using System;

class Program
{
    static void Swap(ref int a, ref int b)
    {
        int temp = a;
        a = b;
        b = temp;
    }

    static void Main()
    {
        int x = 3, y = 7;
        Swap(ref x, ref y);    // ref 를 붙인다
        Console.WriteLine($"{x} {y}");
    }
}

// --- 86 ---
using System;

class Program
{
    // 몫과 나머지를 한꺼번에 돌려주고 싶을 때
    static void Divide(int a, int b, out int mok, out int namuji)
    {
        mok = a / b;
        namuji = a % b;
    }

    static void Main()
    {
        Divide(7, 3, out int m, out int n);
        Console.WriteLine($"몫: {m}, 나머지: {n}");
    }
}

// --- 87 ---
Console.Write("정수를 입력하세요: ");
string input = Console.ReadLine();

if (int.TryParse(input, out int num))
{
    Console.WriteLine($"입력한 값의 두 배는 {num * 2}입니다.");
}
else
{
    Console.WriteLine("숫자가 아닙니다.");
}

// --- 89 ---
using System;

class Program
{
    static void DoubleArray(int[] arr)
    {
        for (int i = 0; i < arr.Length; i++)
        {
            arr[i] = arr[i] * 2;
        }
    }

    static void Main()
    {
        int[] arr = { 1, 2, 3, 4, 5 };
        DoubleArray(arr);     // 크기는 넘기지 않는다

        foreach (int x in arr)
        {
            Console.Write($"{x} ");
        }
    }
}

// --- 90 ---
using System;

class Program
{
    static int SumArray(int[] arr)
    {
        int sum = 0;
        foreach (int x in arr)
        {
            sum += x;
        }
        return sum;
    }

    static void Main()
    {
        int[] arr = { 10, 20, 30, 40, 50 };
        Console.WriteLine($"합: {SumArray(arr)}");
    }
}

// --- 91 ---
using System;

class Program
{
    static float MaxPoint(float[] scores)
    {
        float max = scores[0];
        foreach (float s in scores)
        {
            if (max < s) max = s;
        }
        return max;
    }

    static float MinPoint(float[] scores)
    {
        float min = scores[0];
        foreach (float s in scores)
        {
            if (min > s) min = s;
        }
        return min;
    }

    static float DifPoint(float[] scores)
    {
        return MaxPoint(scores) - MinPoint(scores);
    }

    static void Main()
    {
        float[] points = { 9.5f, 8.8f, 7.0f, 7.9f, 10.0f };
        Console.WriteLine(DifPoint(points));
    }
}

// --- 92 ---
using System;

class Program
{
    static void Count(int a)
    {
        if (a == 0)
        {
            return;          // 종료 조건
        }
        Console.Write($"{a} ");
        Count(a - 1);        // 자기 자신 호출
    }

    static void Main()
    {
        Count(5);
    }
}

// --- 93 ---
using System;

class Program
{
    static int Sum(int n)
    {
        if (n == 0)
        {
            return 0;              // 종료 조건
        }
        return n + Sum(n - 1);     // n + (n-1까지의 합)
    }

    static void Main()
    {
        Console.WriteLine($"1부터 10까지의 합: {Sum(10)}");
    }
}

// --- 94 ---
using System;

class Program
{
    static int Add(int a, int b)
    {
        return a + b;
    }

    static float Add(float a, float b)      // 이름이 같아도 됩니다
    {
        return a + b;
    }

    static int Add(int a, int b, int c)     // 개수가 달라도 됩니다
    {
        return a + b + c;
    }

    static void Main()
    {
        Console.WriteLine(Add(10, 20));
        Console.WriteLine(Add(1.5f, 2.5f));
        Console.WriteLine(Add(10, 20, 30));
    }
}

// --- 96 ---
using System;

class Student
{
    public string name;      // 데이터
    public int score;

    public void Introduce()  // 그 데이터를 다루는 함수
    {
        Console.WriteLine($"{name}의 점수: {score}");
    }
}

class Program
{
    static void Main()
    {
        Student s1 = new Student();
        s1.name = "홍길동";
        s1.score = 95;

        s1.Introduce();
    }
}

// --- 97 ---
Student s1 = new Student();
s1.name = "홍길동";
s1.score = 95;

Student s2 = new Student();
s2.name = "김철수";
s2.score = 45;

s1.Introduce();
s2.Introduce();

// --- 98 ---
class Player
{
    public string name;    // 밖에서 접근 가능
    private int hp;        // 클래스 안에서만 접근 가능
}

// --- 99 ---
using System;

class Player
{
    public string name;
    private int hp = 100;      // 밖에서 직접 못 건드립니다

    public void TakeDamage(int damage)
    {
        hp -= damage;
        if (hp < 0)
        {
            hp = 0;            // 0 밑으로는 내려가지 않게
        }
        Console.WriteLine($"{name}의 남은 체력: {hp}");
    }
}

class Program
{
    static void Main()
    {
        Player p = new Player();
        p.name = "홍길동";

        p.TakeDamage(30);
        p.TakeDamage(90);
        // p.hp = -999;   ← 이 줄은 오류가 납니다
    }
}

// --- 101 ---
using System;

class Student
{
    public string name;
    public int score;

    // 생성자 — 클래스와 이름이 같고, 반환형이 없습니다
    public Student(string name, int score)
    {
        this.name = name;
        this.score = score;
    }

    public void Introduce()
    {
        Console.WriteLine($"{name}의 점수: {score}");
    }
}

class Program
{
    static void Main()
    {
        Student s1 = new Student("홍길동", 95);
        Student s2 = new Student("김철수", 45);

        s1.Introduce();
        s2.Introduce();
    }
}

// --- 102 ---
class Student
{
    public string name;
    public int score;

    public Student(string name, int score)
    {
        this.name = name;
        this.score = score;
    }

    public Student(string name)     // 점수를 안 줬을 때
    {
        this.name = name;
        this.score = 0;
    }
}

// --- 104 ---
using System;

class Student
{
    public string name;
    public int score;

    public Student(string name, int score)
    {
        this.name = name;
        this.score = score;
    }

    public bool IsPass()          // 매개변수가 없습니다
    {
        return score >= 60;
    }

    public void PrintResult()
    {
        if (IsPass())             // 같은 클래스의 메서드는 그냥 부릅니다
            Console.WriteLine($"{name}: 합격");
        else
            Console.WriteLine($"{name}: 불합격");
    }
}

class Program
{
    static void Main()
    {
        Student s1 = new Student("홍길동", 95);
        Student s2 = new Student("김철수", 45);

        s1.PrintResult();
        s2.PrintResult();
    }
}

// --- 105 ---
using System;

class Student
{
    public string name;
    public int score;

    public Student(string name, int score)
    {
        this.name = name;
        this.score = score;
    }

    public void PrintResult()
    {
        if (score >= 60)
            Console.WriteLine($"{name}: {score}점 — 합격");
        else
            Console.WriteLine($"{name}: {score}점 — 불합격");
    }
}

class Program
{
    static void Main()
    {
        Student[] students = {
            new Student("김철수", 85),
            new Student("이영희", 92),
            new Student("박민수", 55)
        };

        int total = 0;
        foreach (Student s in students)
        {
            s.PrintResult();
            total += s.score;
        }

        Console.WriteLine($"전체 평균: {(float)total / students.Length:F1}");
    }
}

// --- 106 ---
using System;

class Calculator
{
    public static int Add(int a, int b)     // static 메서드
    {
        return a + b;
    }
}

class Program
{
    static void Main()
    {
        // 객체를 만들지 않고 클래스 이름으로 바로 부릅니다
        Console.WriteLine(Calculator.Add(10, 20));
    }
}

// --- 107 ---
using System;

class Monster
{
    public static int count = 0;    // 모두가 함께 쓰는 값
    public string name;

    public Monster(string name)
    {
        this.name = name;
        count++;                     // 태어날 때마다 하나씩
    }
}

class Program
{
    static void Main()
    {
        Monster m1 = new Monster("슬라임");
        Monster m2 = new Monster("고블린");
        Monster m3 = new Monster("드래곤");

        Console.WriteLine($"지금까지 태어난 몬스터: {Monster.count}마리");
    }
}

// --- 108 ---
using System;

class Player
{
    private int hp = 100;          // 진짜 값은 감춰 둡니다

    public int Hp                  // 밖에서 쓰는 통로
    {
        get { return hp; }         // 읽을 때
        set
        {
            if (value < 0)         // 쓸 때 검사
                hp = 0;
            else if (value > 100)
                hp = 100;
            else
                hp = value;
        }
    }
}

class Program
{
    static void Main()
    {
        Player p = new Player();

        p.Hp = 70;                 // 변수처럼 씁니다
        Console.WriteLine(p.Hp);

        p.Hp = -999;               // 걸러집니다
        Console.WriteLine(p.Hp);

        p.Hp = 500;                // 이것도 걸러집니다
        Console.WriteLine(p.Hp);
    }
}

// --- 109 ---
public int Hp { get; set; } = 100;      // 검사 없이 통로만
public string Name { get; private set; } // 밖에서는 읽기만 가능

// --- 110 ---
using System;

class Monster                     // 부모 클래스
{
    public string name;
    public int hp;

    public void Attack()
    {
        Console.WriteLine($"{name}이(가) 공격합니다.");
    }
}

class Dragon : Monster            // Monster 를 상속받습니다
{
    public void Fly()             // 드래곤만의 기능을 추가
    {
        Console.WriteLine($"{name}이(가) 날아오릅니다.");
    }
}

class Program
{
    static void Main()
    {
        Dragon d = new Dragon();
        d.name = "붉은용";         // 부모에게서 물려받은 것
        d.hp = 500;

        d.Attack();               // 부모의 메서드
        d.Fly();                  // 자기 메서드
    }
}

// --- 111 ---
using System;

class Monster
{
    public string name;
    public int hp;

    public Monster(string name, int hp)
    {
        this.name = name;
        this.hp = hp;
    }
}

class Dragon : Monster
{
    public int firePower;

    public Dragon(string name, int hp, int firePower) : base(name, hp)
    {
        this.firePower = firePower;
    }
}

class Program
{
    static void Main()
    {
        Dragon d = new Dragon("붉은용", 500, 99);
        Console.WriteLine($"{d.name} 체력 {d.hp} 화력 {d.firePower}");
    }
}

// --- 112 ---
using System;

class Monster
{
    public string name;

    public Monster(string name)
    {
        this.name = name;
    }

    public virtual void Attack()        // 고쳐 써도 좋다
    {
        Console.WriteLine($"{name}이(가) 몸통박치기를 합니다.");
    }
}

class Dragon : Monster
{
    public Dragon(string name) : base(name) { }

    public override void Attack()       // 고쳐 쓰겠다
    {
        Console.WriteLine($"{name}이(가) 불을 뿜습니다!");
    }
}

class Slime : Monster
{
    public Slime(string name) : base(name) { }
    // Attack 을 고치지 않았으므로 부모 것을 그대로 씁니다
}

class Program
{
    static void Main()
    {
        Monster[] monsters = {
            new Slime("슬라임"),
            new Dragon("붉은용")
        };

        foreach (Monster m in monsters)
        {
            m.Attack();
        }
    }
}

// --- 113 ---
public override void Attack()
{
    base.Attack();                  // 부모의 공격을 먼저 실행
    Console.WriteLine("그리고 꼬리로 한 번 더 칩니다.");
}

// --- 114 ---
using System;

class Calculator
{
    private int a;
    private int b;

    public Calculator(int a, int b)
    {
        this.a = a;
        this.b = b;
    }

    public int Plus()  { return a + b; }
    public int Minus() { return a - b; }
    public int Mul()   { return a * b; }
    public float Div()
    {
        if (b == 0)
        {
            Console.WriteLine("0으로 나눌 수 없습니다.");
            return 0;
        }
        return (float)a / b;
    }
}

class Program
{
    static void Main()
    {
        Calculator c = new Calculator(10, 20);

        Console.WriteLine(c.Plus());
        Console.WriteLine(c.Minus());
        Console.WriteLine(c.Mul());
        Console.WriteLine(c.Div());
    }
}

// --- 116 ---
enum PlayerState { Idle, Run, Jump }

PlayerState state = PlayerState.Idle;
if (state == PlayerState.Idle)
{
    Console.WriteLine("대기 중");
}

// --- 117 ---
enum Grade { A = 90, B = 80, C = 70 }

Grade g = Grade.B;
Console.WriteLine(g);          // 이름이 그대로 나옵니다
Console.WriteLine((int)g);     // 숫자로 보고 싶으면 형변환

// --- 118 ---
using System;

enum PlayerState { Idle, Run, Jump }

class Program
{
    static void Main()
    {
        PlayerState state = PlayerState.Run;

        switch (state)
        {
            case PlayerState.Idle:
                Console.WriteLine("가만히 서 있습니다.");
                break;
            case PlayerState.Run:
                Console.WriteLine("달립니다.");
                break;
            case PlayerState.Jump:
                Console.WriteLine("점프합니다.");
                break;
        }
    }
}

// --- 119 ---
using System;

struct Point
{
    public int x;
    public int y;

    public Point(int x, int y)
    {
        this.x = x;
        this.y = y;
    }

    public void Print()
    {
        Console.WriteLine($"({x}, {y})");
    }
}

class Program
{
    static void Main()
    {
        Point p = new Point(10, 20);
        p.Print();
    }
}

// --- 120 ---
using System;

struct PointS { public int x; }     // 구조체 — 값 형식
class  PointC { public int x; }     // 클래스 — 참조 형식

class Program
{
    static void Main()
    {
        PointS s1 = new PointS();
        s1.x = 10;
        PointS s2 = s1;      // 통째로 복사됩니다
        s2.x = 99;

        PointC c1 = new PointC();
        c1.x = 10;
        PointC c2 = c1;      // 같은 것을 함께 가리킵니다
        c2.x = 99;

        Console.WriteLine($"구조체 s1.x = {s1.x}");
        Console.WriteLine($"클래스 c1.x = {c1.x}");
    }
}

// --- 121 ---
using System;

enum Rank { Normal, Elite, Boss }

class Monster
{
    public string name;
    public Rank rank;

    public Monster(string name, Rank rank)
    {
        this.name = name;
        this.rank = rank;
    }

    public void GiveReward()
    {
        switch (rank)
        {
            case Rank.Normal:
                Console.WriteLine($"{name} 처치 — 골드 10");
                break;
            case Rank.Elite:
                Console.WriteLine($"{name} 처치 — 골드 100");
                break;
            case Rank.Boss:
                Console.WriteLine($"{name} 처치 — 골드 1000과 전설 아이템");
                break;
        }
    }
}

class Program
{
    static void Main()
    {
        Monster[] monsters = {
            new Monster("슬라임", Rank.Normal),
            new Monster("오크 대장", Rank.Elite),
            new Monster("붉은용", Rank.Boss)
        };

        foreach (Monster m in monsters)
        {
            m.GiveReward();
        }
    }
}

// --- 122 ---
using UnityEngine;
using System.Collections.Generic;

public enum PlayerState
{
    Idle,
    Run,
    Jump
}

public class Player : MonoBehaviour
{
    public int Hp { get; set; } = 100;
    public float speed = 5f;

    private PlayerState state = PlayerState.Idle;
    private List<string> items = new List<string>();

    void Start()
    {
        items.Add("포션");
        Debug.Log($"게임 시작! HP: {Hp}");
    }

    void Update()
    {
        if (Hp <= 0)
        {
            state = PlayerState.Idle;
            Debug.Log("플레이어가 쓰러졌습니다.");
        }

        switch (state)
        {
            case PlayerState.Run:
                transform.Translate(Vector3.forward * speed * Time.deltaTime);
                break;
        }
    }

    void TakeDamage(int damage)
    {
        Hp -= damage;
    }
}