'전체 글'에 해당되는 글 14건

  1. 2019.10.17 챔피언을 이용한 다른방식
  2. 2019.10.16 Dictionary - 2
  3. 2019.10.15 Dictionary
  4. 2019.10.14 UiPanel 메이플스토리 서버리스트 이미지
  5. 2019.10.14 배수와 리스트
  6. 2019.10.11 리스트
  7. 2019.10.10 배열2
  8. 2019.10.08 배열

챔피언을 이용한 다른방식

/실습 2019. 10. 17. 15:27
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
using System;
using System.Collections.Generic;
 
namespace Syntax043
{
    public class Champion
    {
        public string name;
        public int damage;
 
        public Champion()
        {
            //생성자
 
        }
 
        public  virtual void Attack(Champion target)
        {
            target.Hit(this.damage);
        }
 
        public void Hit(int damage)
        {
            Console.WriteLine("{0}은(는) 피해(-{1})을 받았습니다", this.name, damage);
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using System.Collections.Generic;
 
namespace Syntax043
{
    public class Ashe : Champion
    {
        public Ashe()
        {
 
        }
 
        public override void Attack(Champion target)
        {
            Console.WriteLine(this.name + "가 활을 쏘며" + target.name + "을 공격합니다.");
 
            base.Attack(target);
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax043
{
    public class Garen : Champion
    {
        public Garen()
        {
            
        }
 
        public override void Attack(Champion target)
        {
            Console.WriteLine(this.name + "이 검을 휘두르며" + target.name + "을 공격합니다.");
 
            base.Attack(target);
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax043
{
    public class App
    {
        public App()
        {
            Ashe ashe = new Ashe();
            Garen garen = new Garen();
 
            ashe.name = "애쉬";
            ashe.damage = 10;
            garen.name = "가렌";
            garen.damage = 15;
            ashe.Attack(garen);
            garen.Attack(ashe);
        }
 
       
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

'Console > 실습' 카테고리의 다른 글

Dictionary - 2  (0) 2019.10.16
Dictionary  (0) 2019.10.15
배수와 리스트  (0) 2019.10.14
리스트  (0) 2019.10.11
배열2  (0) 2019.10.10
:

Dictionary - 2

/실습 2019. 10. 16. 14:29
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax042
{
    public class App
    {
        public App()
        {
            Console.WriteLine("Hello World!");
 
            //컬렉션 선언
            Dictionary<int, ItemData> dicItemData;
 
            //컬렉션 객체 생성
            dicItemData = new Dictionary<int, ItemData>();
            
            //데이터들 객체 새성
            var data1 = new ItemData(100"장검",0,"sword_00");
            var data2 = new ItemData(200"가죽옷",0,"leather_clothes_00");
            var data3 = new ItemData(300"체력물약",1,"health_potion_00");
            var data4 = new ItemData(400"금괴",2,"gold_bars_00");
 
            //딕셔너리에 추가 (키:값)
            dicItemData.Add(data1.id, data1);
            dicItemData.Add(data2.id, data2);
            dicItemData.Add(data3.id, data3);
            dicItemData.Add(data4.id, data4);
 
            //검색 : 키값이 100인 itemData
            var foundData = dicItemData[100]; //값 : itemData
            Console.WriteLine("{0} {1}"foundData.id, foundData.name);
 
            //삭제 : 키값이 200인 itemData를 컬렉션에서 제거
            dicItemData.Remove(200);
 
            //출력
            foreach (KeyValuePair<int, ItemData> pair in dicItemData)
            {
                //키 : 아이템의 id
                //값 : ItemData
                //Console.WriteLine("{0} {1}", pair.Key, pair Value);
                var data = pair.Value;
                Console.WriteLine("{0} {1} {2} {3}"data.id, data.name, data.iconName);
            }
        }
 
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

'Console > 실습' 카테고리의 다른 글

챔피언을 이용한 다른방식  (0) 2019.10.17
Dictionary  (0) 2019.10.15
배수와 리스트  (0) 2019.10.14
리스트  (0) 2019.10.11
배열2  (0) 2019.10.10
:

Dictionary

/실습 2019. 10. 15. 16:48
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax039
{
    public class App
    {
        public App()
        {
            //Dictionary : 키 , 값의 컬렉션
 
            //컬렉션 선언
            Dictionary<intstring> dicUsers;
 
            //컬렉션 인스턴스 생성
            dicUsers = new Dictionary<intstring>();
 
            //값 추가
            dicUsers.Add(850516"홍길동1");
            dicUsers.Add(850517"홍길동2");
 
            //값 제거
            var isRemoved = dicUsers.Remove(850518);
            if (isRemoved)
            {
                Console.WriteLine("제거 되었습니다.");
            }
            else
            {
                Console.WriteLine("키값을 찾을수 없어 제거 하지 못했습니다.");
            }
 
            //출력
            Console.WriteLine(dicUsers.Count);
            foreach (KeyValuePair<intstring> pair in dicUsers)
            {
                Console.WriteLine("{0}{1}"pair.Key, pair.Value);
            }
 
            //검색
            Console.WriteLine(dicUsers[850516]);
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax040
{
    public class App
    {
        public App()
        {
            //도감번호 / 몬스터
            //          이름, 공격력, 타입
 
            //Dictionary 컬렉션 선언
            Dictionary<int, Monster> dicMonster;
 
            //컬렉션 인스턴스 생성
            dicMonster = new Dictionary<int, Monster>();
 
            //데이터 추가
            var mon1 = new Monster(1001"이상해씨"1311);
            dicMonster.Add(mon1.id, mon1);
 
            var mon2 = new Monster(1002"피카츄"1708);
            dicMonster.Add(mon1.id, mon2);
 
            //데이터 검색
            var foundMon = dicMonster[1001];
            Console.WriteLine("{0}{1}"foundMon.id, foundMon.name);
 
            //데이터 삭제
            dicMonster.Remove(1001);
 
            //데이터 출력
            foreach (KeyValuePair<int, Monster> pair in dicMonster)
            {
                Monster mon = pair.Value;
                Console.WriteLine("{0}{1}{2}{3}"mon.id, mon.name, mon.damage, mon.type);
            }
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

'Console > 실습' 카테고리의 다른 글

챔피언을 이용한 다른방식  (0) 2019.10.17
Dictionary - 2  (0) 2019.10.16
배수와 리스트  (0) 2019.10.14
리스트  (0) 2019.10.11
배열2  (0) 2019.10.10
:

UiPanel 메이플스토리 서버리스트 이미지

Console/과제 2019. 10. 14. 15:28

 

:

배수와 리스트

/실습 2019. 10. 14. 15:24
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax031
{
    public class App
    {
        public App()
        {
            Console.WriteLine("2019-10-14");
 
            int[] arr = new int[5];
            Console.WriteLine(arr.Length);              //5
            arr[0= 1;
            Console.WriteLine(arr[1]);                  //0
            Console.WriteLine(arr[arr.Length - 1]);     //1
            Console.WriteLine(arr[6]);
 
            List<int> List = new List<int>();
            Console.WriteLine(List.Count);              //0
            List.Add(1);
            Console.WriteLine(List[1]);                 //0
            Console.WriteLine(List[List.Count - 1]);    //1
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax032
{
    public class App
    {
        public App()
        {
            //배열
            Product[] arrProducts = new Product[5];
            //추가
            arrProducts[0= new Product("가방"15000);
            arrProducts[1= new Product("원피스"18000);
            //삭제
            arrProducts[0= null;
 
            Product foundProduct = null;
            string searchProductName = "원피스";
            //검색
            for (int i = 0; i < arrProducts.Length; i++)
            {
                //for문을돌면서 인덱스로 배열의 요소에 접근
                //Product객체 참조 또는 null
                Product product = arrProducts[i];
                if (product != null && product.name == "searchProductName")
                {
                    foundProduct = product;
                    Console.WriteLine(product.name + "을 찾았습니다.");
                }
            }
            if (foundProduct == null)
            {
                Console.WriteLine("{0}을(를) 찾지 못했습니다.", searchProductName);
            }
            else
            {
                Console.WriteLine(foundProduct.name + "을(를) 찾았습니다.");
            }
 
 
 
 
        }
        
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

'Console > 실습' 카테고리의 다른 글

Dictionary - 2  (0) 2019.10.16
Dictionary  (0) 2019.10.15
리스트  (0) 2019.10.11
배열2  (0) 2019.10.10
배열  (0) 2019.10.08
:

리스트

/실습 2019. 10. 11. 11:35
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax030
{
    public class App
    {
        public App()
        {
            Console.WriteLine("2019-10-11");
 
            //Product개채들을 관리 하기 위해 컬렉션 List 클래스의 인스턴스를 생성함.
            List<Product> productList = new List<Product>();
 
            //Product개체를 만듬
            Product p1 = new Product("운동화"2500);
            Product p2 = new Product("후드티"3300);
            //리스트에 추가
            productList.Add(p1);
 
            //리스트 요소 출력
            DisplayProducts();
 
            //리스트 요소 제거
            bool success = productList.Remove(p2);
            Console.WriteLine("succes: {0}", success);
 
            //리스트 요소 출력
            DisplayProducts();
 
            //리스트 요소들의 갯수 출력
            Console.WriteLine("Count: {0}"productList.Count);
 
            //인덱스 접근
            Console.WriteLine("----> " + productList[0].name);
 
 
        }   
        public void DisplayProducts()
        {      
            //리스트 요소 출력
            for (int i = 0; i < productList.Count; i++)
                
                Product product = productList[i];
                Console.WriteLine("{0}:{1}, product.name, product.cost");
            }
 
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax030
{
    public class Product
    {
        public int cost;
        public string name;
 
        public Product(string name, int cost)
        {
 
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax030
{
    public class App
    {
        public List<Product> productList;
        public App()
        {
            Console.WriteLine("2019-10-11");
 
            //product개채들을 관리 하기 위해 컬렉션 List 클래스의 인스턴스를 생성함.
            productList = new List<Product>();
 
            //Product개체를 만듬
            Product p1 = new Product("운동화"2500);
 
            //리스트에 추가
            productList.Add(p1);
 
            //리스트 요소 출력
            DisplayProducts();
 
            //Product개체 생성
            Product p2 = new Product("후드티"3300);
 
            //리스트에 추가
            productList.Add(p2);
 
            //리스트 요소 출력
            DisplayProducts();
 
            //리스트 요소 제거
            bool success = productList.Remove(p2);
            Console.WriteLine("succes: {0}", success);
 
            //리스트 요소 출력
            DisplayProducts();
 
            //리스트 요소들의 갯수 출력
            Console.WriteLine("Count: {0}"productList.Count);
 
            //인덱스 접근
            Console.WriteLine("---->" + productList[0].name);
 
        }//end of App
 
     public void DisplayProducts()
        {
            //리스트 요소 출력
            for (int i = 0; i < productList.Count; i++)
            {
                Product product = productList[i];
                Console.WriteLine("{0}:{1}"product.name, product.cost);
            }
        }    
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

'Console > 실습' 카테고리의 다른 글

Dictionary  (0) 2019.10.15
배수와 리스트  (0) 2019.10.14
배열2  (0) 2019.10.10
배열  (0) 2019.10.08
메서드 3  (0) 2019.10.07
:

배열2

/실습 2019. 10. 10. 16:26
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax027
{
    public class app
    {
        //배열선언
        product[] arrProducts;
 
        public app()
        {
            Console.WriteLine("2019-10-10");
            //배열초기화
            arrProducts = new product[5];
 
            //객체 생성
            var product1 = new product(2500"운동화");
 
            //배열에 추가
            arrProducts[0= product1;
            arrProducts[1= new product(3300"후드티");
 
            //배열의 요소 출력
            Displayproducts();
 
            //배열의 요소중 가격이 2500원인 것 찾기
 
            //배열의 모든 요소를 반복하면서 찾는다.
            //요소중 가격이 2500인것을 찾는다.
            for (int i = 0; i < arrProducts.Length; i++)
            {
                
            }
            foreach (var product in arrProducts)
            {
                
            }
            int k = 0;
            while (true)
            {
                if (k > arrProducts.Length - 1)
                {
                    break;
                }
                k++;
 
            }
 
        }
            public void Displayproducts()
            {
            foreach (product product in arrProducts)
            {
                if (product != null)
                    Console.WriteLine(product.name);
            }
 
            //int[] arrcost = new int[5];
            //string[] arrNames = new string[5];
 
            //arrcost[0] = 2500;
            //arrNames[0] = "운동화";
 
            //arrcost[1] = 3300;
            //arrNames[1] = "후드티";
 
            ////for(int i = 0; i < arrcost.Length; i++)
            ////
            ////    int cost = arrcost[i];
            ////    string name = arrNames[i];
            ////    Console.WriteLine("{0}:{1}원", name, cost);
 
            //int i = 0;
            //foreach (int cost in arrcost)
            //{
            //    string name = arrNames[i];
            //    Console.WriteLine("{0}:{1}원", name, cost);
            //    i++;
            //}
           
           
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax027
{
    public class product
    {
        public int cost;
        public string name;
 
        //생성자
        public product(int cost, string name)
        {
            this.cost = cost;
            this.name = name;
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 
 
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
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax028
{
    public class inventory
    {
        public item[] arritems;
        public int idx;
        public inventory()
        {
            this.arritems = new item[5];
        }
        public void Additem(item item)
        {
            this.arritems[idx++= item;
        }
 
        public item Finditembyname(string name)
        {
            for(int i = 0; i< arritems.Length; i++)
            {
                item item = arritems[i];       
                {
                    if (item !=null && item.name == name)
                    {
                        return item;
                    }
                }
                
            }
            return null;
        }
    }
 
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax028
{
    public class item
    {
        public int id;
        public string name;
        public item(int id, string name)
        {
            this.id = id;
            this.name = name;
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax028
{
    public class App
    {
        public App()
        {
            inventory inventory = new inventory();
            inventory.Additem(new item(100"장검"));
            inventory.Additem(new item(200"단검"));
            item item = inventory.Finditembyname("장검");
            if (item == null)
            {
                Console.WriteLine("아이템 검색실패");
            }
            else
            {
                Console.WriteLine("{0}을 찾았습니다."item.name);
            }
            
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

 

'Console > 실습' 카테고리의 다른 글

배수와 리스트  (0) 2019.10.14
리스트  (0) 2019.10.11
배열  (0) 2019.10.08
메서드 3  (0) 2019.10.07
메서드 2  (0) 2019.10.01
:

배열

/실습 2019. 10. 8. 11:51
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax024
{
    public class App
    {
        public App()
        {
            int[] arr = new int[5];
            for (int i = 0; i < arr.Length; i++)
            {
                Console.WriteLine(arr[i]);
            }
 
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax024
{
    public class App
    {
        public App()
        {
            float[] arr = new float[5];
 
            arr[0= 3.14f;
 
            for (int i = 0; i < arr.Length; i++)
            {
                Console.WriteLine(arr[i]);
            }
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax024
{
    public class App
    {
        public App()
        {
            Pizza[] arr = new Pizza[5];
            arr[0= new Pizza("고르곤졸라");
            arr[1= new Pizza("꿈을피자");
            arr[2= new Pizza("쉬림프피자");
            arr[3= new Pizza("단호박골드피자");
            arr[4= new Pizza("치즈피자");
            for (int i= 0; i < arr.Length; i++)
            {
                Pizza pizza = arr[i];
                Console.WriteLine(arr[i]);
            }
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax025
{
    public class App
    {
        public App()
        {
            string[] arritemNames = new string[5];
            arritemNames[0= "장검";
            arritemNames[1= "단검";
            arritemNames[2= "활";
            arritemNames[3= "도끼";
            arritemNames[4= "창";
 
            Item[] arritems = new Item[5];
 
            for (int i = 0; i < arritems.Length; i++)
            {
                arritems[i] = new Item(arritemNames[i]);
            }
        }
 
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 
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
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax026
{
    class inventory
 
    {
        public item[] items;
        public int itemindex;
        public inventory()
        {
            this.items = new item[5];
        }
 
 
        public void Additem(item item)
        {
            this.items[itemindex] = item;
            itemindex++;
        }
 
        public void GetItem(string itemName)
        {
            for (int i = 0; i < this.items.Length; i++)
            {
                if(this.items[i].name == itemName)
                {
                    break;
                }
            }
            return founditem
 
        }
    }
 
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 
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
32
33
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax026
{
    public class App
    {
        public App()
        {
            inventory inventory = new inventory();
            inventory.Additem(new item("장검"));
            inventory.Additem(new item("단검"));
            inventory.Additem(new item("활"));
            inventory.Additem(new item("도끼"));
            inventory.Additem(new item("창"));
 
            item founditem = inventory.GetItem("단검");
            if (founditem != null)
            {
                Console.WriteLine(founditem.name + "을 찾았습니다.");
            }
            else
            {
                Console.WriteLine("아이템을 찾을수 없습니다.");
            }
 
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 
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
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax026
{
    public class inventory
 
    {
        public item[] items;
        public int itemindex;
        public inventory()
        {
            this.items = new item[5];
        }
 
 
        public void Additem(item item)
        {
            this.items[itemindex] = item;
            itemindex++;
        }
 
        public item GetItem(string itemName)
        {
            item founditem = null;
 
            for (int i = 0; i < this.items.Length; i++)
            {
                if(this.items[i].name == itemName)
                {
                    break;
                }
            }
            return founditem;
 
        }
    }
 
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

'Console > 실습' 카테고리의 다른 글

리스트  (0) 2019.10.11
배열2  (0) 2019.10.10
메서드 3  (0) 2019.10.07
메서드 2  (0) 2019.10.01
메서드 1  (0) 2019.09.30
: