using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
interface Ilnteractable
{
// public이 아니어도 외부에서 사용 가능?
void Interact();
}
abstract class NPC
{
int _x;
int _y;
string _name;
}
class EnforceNpc : NPC, Ilnteractable
{
public void Interact()
{
Console.WriteLine("강화를 수행합니다");
}
}
class StorageNpc : NPC, Ilnteractable
{
public void Interact()
{
Console.WriteLine("창고 상호작욕을 수행합니다");
}
}
class JobNpc : NPC
{
}
class Player
{
int _x;
public Ilnteractable _ilnteractable;
// !!!!
public void InteractWithNPC(Ilnteractable ilnteractable)
{
_ilnteractable = ilnteractable;
Console.WriteLine(" 상호 작용 시도 ");
_ilnteractable.Interact();
}
}
internal class Program
{
static void Main(string[] args)
{
Player player = new Player();
StorageNpc storageNpc = new StorageNpc();
JobNpc jobNpc = new JobNpc();
EnforceNpc enforceNpc = new EnforceNpc();
player.InteractWithNPC(enforceNpc);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace test
{
enum Type
{
Normal, Fire, Water, Grass, Ghost, Electricity
}
class Trainer
{
int _vetge;
string _nameTrainer;
Poketmon[] _poketmons;
public Trainer(string name)
{
_poketmons = new Poketmon[6];
}
public Trainer()
{
_poketmons = new Poketmon[6];
}
public Trainer(Poketmon poketmon)
{
_poketmons = new Poketmon[6];
_poketmons[0] = new Pikachu(1, "피카츄1");
}
public void PoketmonChoose(Poketmon poketmon)
{
for (int i = 0; i < _poketmons.Length; i++)
{
_poketmons[i] = poketmon;
Console.WriteLine(_poketmons[i]);
}
}
}
class Poketmon
{
protected int _lever;
protected Type _type;
protected string _namePoketmon;
public Poketmon()
{
_lever = 1;
_type = Type.Normal;
_namePoketmon = " 기본 포켓몬";
}
public Poketmon(int lever, Type type, string namePoketmon)
{
_lever = lever;
_type = type;
_namePoketmon = namePoketmon;
}
}
class Pikachu : Poketmon
{
public Pikachu(int lever, string namePoketmon)
{
}
}
class Squirtle : Poketmon
{
public Squirtle(int lever, string namePoketmon)
{
}
}
class Bulbasaur : Poketmon
{
public Bulbasaur(int lever, string namePoketmon)
{
}
}
class Charmander : Poketmon
{
public Charmander(int lever, string namePoketmon)
{
}
}
internal class Program
{
static void Main(string[] args)
{
Trainer trainer = new Trainer();
Poketmon Poketmon = new Pikachu(1, "aa");
// Poketmon[] Poketmons = new ;
trainer.PoketmonChoose(Poketmon);
//monster._type = MobType.Nomal;
//monster._nameMon = "거북이";
//monster._level = 1;
}
}
}