1. 파일 분리 , Player 작업
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _240330
{
// 똑같이 열거형
enum PlayerType
{
None = 0,
Warrial = 1,
Archer = 2,
Magition = 3,
}
internal class Player
{
protected PlayerType type;
protected int hp = 0;
protected int attack = 0;
protected Player(PlayerType type) // 아무것도 인자가 없으면 사용 불가
{
this.type = type;
}
public void SetInfo(int hp, int attack) // 직접 적기
{
this.hp = hp;
this.attack = attack;
}
// 외부에서 궁금할 수 있어서
public int GetHp() { return hp; }
public int GetAttack() { return attack; }
}
class Warrial : Player
{
// 생성자
public Warrial() : base(PlayerType.Warrial)
{
SetInfo(100, 10);
}
}
class Archer : Player
{
public Archer() : base(PlayerType.Archer)
{
SetInfo(80, 12);
}
}
class Magition : Player
{
public Magition() : base(PlayerType.Magition)
{
SetInfo(70, 15);
}
}
}