Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

행복한 개구리

C# 21.03.25.복습 본문

C#/복습

C# 21.03.25.복습

HappyFrog 2021. 3. 25. 17:32
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Homework1234
{
    
    class App
    {
        public App()
        {
            Console.WriteLine("App");

            ItemData data = new ItemData(1, "천 옷", eGrade.Rare);
            Item item = new Item(data);
            User user = new User();

            user.StartCrafting(item);

            user.completeCrafting();

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

namespace Homework1234
{
    public enum eGrade
    {
        Normal, Rare, Unique, Legendary
    }
    public class ItemData
    {
        public int id;
        public string name;
        public eGrade grade;
        public ItemData(int id, string name, eGrade grade)
        {
            this.id = id;
            this.name = name;
            this.grade = grade;
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Homework1234
{
    public class Item
    {
        public ItemData data;
        public Item(ItemData data)
        {
            this.data = data;
        }

        public void CompleteCrafting()
        {
            Console.WriteLine("제작이 완료되었습니다.");
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Homework1234
{

    public delegate void DelCompleteCrafting();
    
    public class User
    {
        public DelCompleteCrafting completeCrafting;
        
        
        public void StartCrafting(Item item)
        {
            Console.WriteLine("{0}을 만듭니다. ID : {1} / 등급 : {2}", item.data.name, item.data.id,item.data.grade);
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine("제작중.....  {0}%", i * 10);
                Thread.Sleep(500);
            }
            this.completeCrafting = item.CompleteCrafting;
        }
    }
}

 

'C# > 복습' 카테고리의 다른 글

C# 21.04.05.복습  (0) 2021.04.05
C#21.03.29.복습  (0) 2021.03.29
C#21.03.26~28.복습  (0) 2021.03.26
C# 21.03.23.복습  (0) 2021.03.23