mynote6590 2024. 12. 16. 15:14
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace ConsoleApp2
{
    class UsableItem
    {
        string _name;
        int _price;
        int _mount;


        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        public int Price
        {
            get { return _price; }
            set { _price = value; }
        }

        public int Amount
        {
            get { return _mount; }
            set { _mount = value; }
        }


    }

    class Player
    {
        List<UsableItem> items = new List<UsableItem>();
        List<Weapon> weapons = new List<Weapon>();
        bool paymentCheck;
        // int count = 1;
        ConsoleKeyInfo ConsoleKeyInput;


        public void PrintUsablArr()
        {
            for (int i = 0; i < items.Count; i++)
            {
                Console.WriteLine(i + " 번째 아이템 ");
                Console.WriteLine("아이템 이름" + items[i].Name);
                Console.WriteLine("아이템 가격" + items[i].Price);
                
            }
        }

        public void PrintWeaponArr()
        {
            for (int i = 0; i < weapons.Count; i++)
            {

            }
        }


        public bool PaymentCheckFun()
        {
            if (items.Count < 3)
            {
                paymentCheck = true;
            }
            else
            {
                paymentCheck = false;
            }

            return paymentCheck;
        }

        public void AddItem(UsableItem usable)
        {
            Console.Clear();

            while (true)
            {
                Console.Write("아이템 이름 : ");
                usable.Name = Console.ReadLine();
                Console.Write("아이템 가격 : ");
                int.TryParse(Console.ReadLine() ,out int temp);
                usable.Price  = temp;
                Console.Write("아이템 수량 : ");
                int.TryParse(Console.ReadLine(), out temp);
                usable.Amount = temp;
                PaymentCheckFun();
                if (paymentCheck == true)
                {
                    items.Add(usable);
                }
                else
                {
                    Console.WriteLine("돈 내세요");
                    break;
                }
            }

        }

        public void AddWeapon(Weapon weapon)
        {

        }

        public void ChoosePlayer()
        {
            UsableItem usable = new UsableItem();
            Weapon weapon = new Weapon();

            Console.WriteLine("1. 아이템 추가");
            Console.WriteLine("2. 무기 추가");
            Console.WriteLine("3. 아이템 목록");
            Console.WriteLine("4. 무기 목록");
            //Console.WriteLine();

            while (true)
            {
                ConsoleKeyInput = Console.ReadKey(true);
                //if (ConsoleKeyInput.Key == ConsoleKey.D1 || ConsoleKeyInput.Key == ConsoleKey.D2
                //    || ConsoleKeyInput.Key == ConsoleKey.D3 || ConsoleKeyInput.Key == ConsoleKey.D4)
                //{
                //    break;
                //}

                if (ConsoleKeyInput.Key == ConsoleKey.D1)
                {
                    AddItem(usable);
                }
                else if (ConsoleKeyInput.Key == ConsoleKey.D2)
                {
                    AddWeapon(weapon);
                }
                else if (ConsoleKeyInput.Key == ConsoleKey.D3)
                {


                }
                else if (ConsoleKeyInput.Key == ConsoleKey.D4)
                {


                }
                else
                {
                    Console.WriteLine("다시 입력");
                }
            }


        }

    }

    class Weapon
    {
        string name;
        int str;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        public int Str
        {
            get { return str; }
            set
            {
                str = value;
            }
        }

        public void WeaponAttact()
        {

        }
    }
    internal class Program
    {
        static void Main(string[] args)
        {

            Player player = new Player();


            player.ChoosePlayer();


        }
    }
}