c#/복습 공부

세미평가 아이템 넣기 다시 시도(실패)

이지훈26 2021. 9. 14. 00:03
using System;
using Helloworld;

namespace HelloWorld
{
    class Program
    {

        static void Main(string[] args)
        {
            App app = new App();
        }
            
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Helloworld
{
    class App
    {
        //생성자 
        public App()
        {
            Inventory inventory = new Inventory();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace Helloworld
{
    class Inventory
    {
        
        public Inventory()
        {
            Console.Write("입력하세요 : ");
            Console.ReadLine();

            List<string> arr = new List<string>();
            arr.Add("1개 :: 사루 동굴 지도");
            arr.Add("10개 :: 횃불");
            arr.Add("2개 :: 하누리 지도");

            for (int i = 0; i < arr.Count; i++)
            {
                Console.WriteLine(arr[i]);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Helloworld
{
    class Item
    {
        public string name;
        public Item(string name)
        {
            this.name = name;

        }
    }
}

일반화 클래스 제네릭 List<T> 를 사용해서 표현하고 싶은데, 막히면 딴길로 간다;;

 

소지품 안에 아이템들이 나타나게 한다.
그럼 소지품 메서드를 만들어서 안에 넣는다
소지품을 쓰면 아이템들이 출력된다.

이렇게 만들고 싶다.

 

출력이 되고 횃불을 버리고 잡고 하려면 뭘 해야 할까..?

다른 컬렉션을 사용해야 하나?

뭘 사용해야하지?

결국 소지품 메서드도 만들지 못했다; 뭘 써도 아이템이 출력된다;;