using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Transactions;
using static CSharp.Program;
namespace CSharp
{
//객체 (OOP Object Oriented Programming)
//Knight
//속성 : hp , attack, pos;
//기능 : Move, Attack, Die;
class Knight
{
public int hp;
public int attack;
public Knight()
{
hp = 100;
attack = 10;
Console.WriteLine("생성자 호출!");
}
public Knight(int hp) : this()
{
this.hp = hp;
Console.WriteLine("int 생성자 호출!");
}
public Knight(int hp, int attack):this(hp)
{
this.hp = hp;
this.attack = attack;
Console.WriteLine("int, int 생성자 호출!");
}
public Knight Clone()
{
Knight knight = new Knight();
knight.hp = hp;
knight.attack = attack;
return knight;
}
public void Move()
{
Console.WriteLine("Knight Move");
}
public void Attack()
{
Console.WriteLine("Knight Attack");
}
}
class Program
{
static void Main(string[] args)
{
Knight knight = new Knight(50, 10);
}
}
}
C#
생성자
728x90
반응형
반응형