728x90
App 클래스
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
using starcraft;
using System.Data;
namespace starcraft
{
public class App
{
//생성자
public App()
{
//영웅 생성
Hero hero = new Hero();
hero.attackComplete = () => {
Console.WriteLine("공격완료");
};
hero.Attack();
hero.Move(() => {
Console.WriteLine("이동완료");
});
}
}
}
Hero 클래스
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace starcraft
{
public class Hero
{
public Action attackComplete;
//생성자
public Hero()
{
Console.WriteLine("영웅이 생성되었습니다.");
Console.WriteLine();
}
//공격 메서드
public void Attack()
{
Console.WriteLine("공격중...");
Console.WriteLine("공격중...");
Console.WriteLine("공격중...");
Console.WriteLine("공격을 완료하였습니다.");
attackComplete();
}
//이동 매서드
public void Move(Action callback)
{
Console.WriteLine("이동중...");
Console.WriteLine("이동중...");
Console.WriteLine("이동중...");
Console.WriteLine("이동을 완료하였습니다.");
callback();
}
}
}
'KDT > C# 프로그래밍' 카테고리의 다른 글
23/07/27 아이템 정보 저장하기 (0) | 2023.07.27 |
---|---|
23/07/27 대리자 연습 (0) | 2023.07.27 |
23/07/27 데이터매니저 데이터로드 (0) | 2023.07.27 |
23/07/27 람다 (0) | 2023.07.27 |
23/07/27 대리자 (0) | 2023.07.27 |