using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Study_012
{
class APP1
{
public APP1()
{
// //리스트 객체 생성
//List<string> list = new List<string>();
// //값을추가
// //리스트 길이
// //인덱스로 접근해서 가져오거나 설정할 수 있다.
// //list[0] = "lim";
// //index 요소는 카운트가 0 이랑 같거나 클경우 에러남
// //for문으로 요소 출력
// {
// Console.WriteLine(list[i]);
// }
// Console.WriteLine("-------------------------");
// foreach(string name in list)
// {
// Console.WriteLine(name);
// }
// //hong 문자열과 같은 요소를 찾는다
// string foundName = "";
// foreach(string name in list)
// {
// if (name == "hong")
// {
// //찾은 경우
// foundName = name;
// }
// break;
// }
// Console.WriteLine("----> {0}", foundName);
// Console.WriteLine("fondName2 : {0}", foundname2);
// foreach (var name in list)
// {
// Console.WriteLine(name);
// }
//리스트<Item> 객체 생성
//Item
// ㄴ 멤버 : name, amount
//리스트에 Item 객체 추가
//리스트에 있는 Item 객체의 name 과 amount를 출력
// 객체 3개정도
//List<Item> itemlist = new List<Item>();
//foreach(Item item in itemlist)
//{
//}
//// list 안에 item 찾기 (name이 "장검")
//// 아이템을 찾았습니다: 장검
//foreach(Item item in itemlist)
//{
// {
// }
//}
//Console.WriteLine("------------------------------------------");
//{
// if(itemlist[i].name == "숏소드")
// {
// Console.WriteLine("아이템을 찾았습니다 : {0}", itemlist[i].name);
// }
//}
//Console.WriteLine("------------------------------------------");
//Console.WriteLine("------------------------------------------");
//장검 9개를 습득한걸로
//List<Item> itemlist = new List<Item>();
//인벤토리 안 리스트 안을 통해 관리
//Inventory inventory = new Inventory();
//inventory.PrintAllItems();
//inventory.GetItemByName("숏소드");
List<Item> dropItemlist = new List<Item>();
var Item = new Item("롱소드", 10);
var Item1 = new Item("숏소드", 2);
var Item2 = new Item("활", 5);
Console.WriteLine("떨어져있는 아이템");
Console.WriteLine("--------------------------");
this.PrintDropItemList(dropItemlist);
Console.WriteLine("소지중인 아이템");
Console.WriteLine("--------------------------");
}
public void PrintDropItemList(List<Item> list)
{
int i = 0;
foreach ( var item in list)
{
{
Console.WriteLine();
}
else
{
}
i++;
}
Console.WriteLine("--------------------------");
}
}
}
==========================================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Study_012
{
class Item
{
public string name;
public int amount;
public Item(string name, int amount)
{
this.name = name;
this.amount = amount;
}
}
}
=============================================================================================