using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
class ItemDatabase
{
public Dictionary<string, BaseItem> itemDB = new Dictionary<string, BaseItem>();
// 무기 / 방어구
public ItemDatabase()
{
BaseItem weapon = new BaseItem();
weapon.itemName = "무기";
weapon.type = 1;
weapon.power = 5;
weapon.price = 1000;
BaseItem shield = new BaseItem();
shield.itemName = "방패";
shield.type = 2;
shield.power = 4;
shield.price = 2000;
itemDB.Add(weapon.itemName, weapon);
itemDB.Add(shield.itemName, shield);
}
public BaseItem GetItem(string name)
{
if(itemDB.ContainsKey(name))
{
return itemDB[name];
}
else
{
return null;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
internal class BaseItem
{
public int index;
public string itemName;
public int type;
public int power;
public int price;
}
}
namespace ConsoleApp2
{
internal class Program
{
static void Main(string[] args)
{
ItemDatabase itemDB = new ItemDatabase();
BaseItem a = itemDB.GetItem("무기");
BaseItem b = itemDB.GetItem("방패");
Console.WriteLine("!!");
Console.WriteLine("Hello, World!");
Console.WriteLine("Stop!!");
}
}
}