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

  1. 2019.10.14 UIPanel 제작
  2. 2019.10.10 인벤토리에 아이템 넣고 빼기
  3. 2019.10.02 Class mathod
  4. 2019.10.02 class mathod
  5. 2019.10.01 Claas를 이용한 버거 만들기
  6. 2019.09.30 백준 2438번 문제

UIPanel 제작

Console(콘솔)/실습 2019. 10. 14. 15:27

 

- 달빛조각사M 게임 콘텐츠 내 출석이벤트 UIPanel 제작-

 

 

 

'Console(콘솔) > 실습' 카테고리의 다른 글

인벤토리에 아이템 넣고 빼기  (0) 2019.10.10
Class mathod  (0) 2019.10.02
class mathod  (0) 2019.10.02
Claas를 이용한 버거 만들기  (0) 2019.10.01
method문 사용  (0) 2019.09.30
:

인벤토리에 아이템 넣고 빼기

Console(콘솔)/실습 2019. 10. 10. 15:28

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace Syntax51

{

    class Program

    {

        static void Main(string[] args)

        {

            new App();

        }

    }

}

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace Syntax51

{

    class App

    {

        public App()

        {

            var inventory = new Inventory();

            inventory.AddItem(new Item(100"장검"));

            inventory.AddItem(new Item(200"단검"));

            inventory.AddItem(new Item(300"대검"));

            inventory.AddItem(new Item(400"창"));

            inventory.AddItem(new Item(500"활"));

 

            inventory.FindItemByName("장검");           

            inventory.FindIndexofItemByName("단검");

            inventory.DisplayInventoryItemNames();

            inventory.RemoveItemByName("장검");

            inventory.DisplayInventoryItemNames();

            inventory.AddItem(new Item(600"도끼"));

            inventory.DisplayInventoryItemNames();

            inventory.AddItem(new Item(600"도끼"));

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace Syntax51

{

    class Inventory

    {

        public Item[] arrItems;

        public int index=0;

        public Inventory()

        {

            this.arrItems = new Item[5];

        }

        public void AddItem(Item item)

        {

            for (int i = 0; i < arrItems.Length; i++)

            {

                if (arrItems[i] == null)

                {

                    this.arrItems[i] = item;

                    Console.WriteLine(item.name+"이 생성되었습니다.");

                    return;

                }               

            }

            Console.WriteLine("공간이부족합니다.");

            

        }

        public void RemoveItemByName(string name)

        {

 

            for (int i = 0; i < arrItems.Length; i++)

            {

                if (arrItems[i].name == name)

                {

                    arrItems[i] = null;

                    break;

                }

                else

                {

                    Console.WriteLine("해당상품이 없습니다.");

                }

            }

        }

        public void DisplayInventoryItemNames()

        {

            for (int i = 0; i < arrItems.Length; i++)

            {

                if (arrItems[i] != null)

                {

                    Console.Write(arrItems[i].name+" ");

                }                             

            }

            Console.WriteLine();

        }

        public int FindIndexofItemByName(string name)

        {

            for (int i = 0; i < arrItems.Length; i++)

            {

                if (arrItems[i].name != null&& arrItems[i].name == name)

                {

                    Console.WriteLine(arrItems[i].id);

                    return arrItems[i].id;

                }              

            }

            Console.WriteLine("해당 아이템을 찾을수 없습니다.");

            return 0;

 

        }

        public Item FindItemByName(string name)

        {

            for (int i = 0; i < arrItems.Length; i++)

            {

                if (arrItems[i] != null && name == arrItems[i].name)

                {

                    Console.WriteLine($"{arrItems[i].name}을 찾았습니다.");

                    return arrItems[i];

                }

                Console.WriteLine("아이템을 찾을 수 없습니다.");

                return null;

            }

            

            return null;

 

        }   

    }

}

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace Syntax51

{

    class Item

    {

        public int id;

        public string name;

        public Item(int id, string name)

        {

            this.id = id;

            this.name = name;

        }

    }

}

 

'Console(콘솔) > 실습' 카테고리의 다른 글

UIPanel 제작  (0) 2019.10.14
Class mathod  (0) 2019.10.02
class mathod  (0) 2019.10.02
Claas를 이용한 버거 만들기  (0) 2019.10.01
method문 사용  (0) 2019.09.30
:

Class mathod

Console(콘솔)/실습 2019. 10. 2. 16:46

메소드를 이용한 스타크래프트 예시

마린을 생성한후 마린1과 마린2를 싸우게한다.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace Syntax39

{

    class Program

    {

        static void Main(string[] args)

        {

            new App();

        }

    }

}

 

Colored by Color Scripter

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace Syntax39

{

    class App

    {

        public App()

        {

            Tower tower=new Tower();

            tower.name = "배럭스";

            Console.WriteLine(tower.name);

            tower.MakeUnit("마린1",10,100);

            tower.MakeUnit("마린2",10,100);

            Unit unit1=new Unit("마린1",10,100);           

            Unit unit2 = new Unit("마린2",10,100);

            unit1.Attack(unit2);

            unit2.Hit(unit1);

        }

    }

}

 

Colored by Color Scripter

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace Syntax39

{

    class Tower

    {

        public string name;

        public Tower()

        {

            

        }

        public void MakeUnit(string name, int damage,int hp)

        {

            Unit unit=new Unit(name,damage,hp);

            unit.name = name;

            Console.WriteLine(name+"(이)가 생성되었습니다.");

        }

    }

}

 

Colored by Color Scripter

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace Syntax39

{

    class Unit

    {       

        public string name;

        public int hp;

        public int damage;

        public int maxhp;

 

        public Unit(string name,int hp, int damage)

        {

            this.name = name;

            this.hp = hp;

            this.damage = damage;

            this.maxhp = this.hp;

            

        }

        public void Attack(Unit taget)

        {

            this.hp = hp - this.damage;

            Console.WriteLine($"{this.name}(이)가 {taget.name}(을)를 공격하였습니다.");

            

        }

        public void Hit(Unit taget)

        {

            this.hp = hp - this.damage;

            Console.WriteLine($"{this.name}(이)가 {taget.name}에게 공격당하였습니다.");

            Console.WriteLine($"{this.name}의 체력은 {this.hp}입니다.");

        }

    }

}

 

Colored by Color Scripter

'Console(콘솔) > 실습' 카테고리의 다른 글

UIPanel 제작  (0) 2019.10.14
인벤토리에 아이템 넣고 빼기  (0) 2019.10.10
class mathod  (0) 2019.10.02
Claas를 이용한 버거 만들기  (0) 2019.10.01
method문 사용  (0) 2019.09.30
:

class mathod

Console(콘솔)/실습 2019. 10. 2. 16:43

메소드를 이용하여 음료 자판기 만들기

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace Syntax25

{

    class Program

    {

        static void Main(string[] args)

        {

            new App();

        }

    }

}

 

Colored by Color Scripter

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace Syntax25

{

    class App

    {

        public App()

        {

            Machine machine = new Machine("음료자판기");

                       

            Console.WriteLine("-----------------------");

            

            machine.MakeDrink("칠성사이다");

            machine.MakeDrink("비락식혜");

            machine.MakeDrink("코카콜라");

        }

    }

}

 

Colored by Color Scripter

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace Syntax25

{

    class Machine

    {

        public string name;

        public Machine(string name)

        {

            this.name = name;

            Console.WriteLine(name);

 

        }

        public void MakeDrink(string name)

        {

            Drink drink = new Drink(name);

            

        }

    }

}

 

Colored by Color Scripter

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace Syntax25

{

    class Drink

    {

        public string name;

        public Drink(string name)

        {

            this.name = name;

            Console.WriteLine(name + "가 생성되었습니다.");

 

        }

 

    }

}

 

Colored by Color Scripter

 

'Console(콘솔) > 실습' 카테고리의 다른 글

인벤토리에 아이템 넣고 빼기  (0) 2019.10.10
Class mathod  (0) 2019.10.02
Claas를 이용한 버거 만들기  (0) 2019.10.01
method문 사용  (0) 2019.09.30
enum 문제  (0) 2019.09.27
:

Claas를 이용한 버거 만들기

Console(콘솔)/실습 2019. 10. 1. 15:19

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace Syntax20

{

    class Program

    {

        static void Main(string[] args)

        {

            new App();

        }

    }

}

 

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace Syntax20

{

    class App

    {

        public App()

        {

            Macdonald macdonald1 = new Macdonald();

            macdonald1.name = "1955 버거";

            Console.WriteLine(macdonald1.name + "가 만들어졌습니다.");

            Macdonald macdonald2 = new Macdonald();

            macdonald2.name = "빅맥 버거";

            Console.WriteLine(macdonald2.name + "가 만들어졌습니다.");

            Macdonald macdonald3 = new Macdonald();

            macdonald3.name = "슈슈 버거";

            Console.WriteLine(macdonald3.name + "가 만들어졌습니다.");

            Macdonald macdonald4 = new Macdonald();

            macdonald4.name = "슈비 버거";

            Console.WriteLine(macdonald4.name + "가 만들어졌습니다.");

        }

    }

}

 

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace Syntax20

{

    class Macdonald

    {

        public string name;

        public Macdonald()

        {

 

        }

    }

}

 

 

'Console(콘솔) > 실습' 카테고리의 다른 글

Class mathod  (0) 2019.10.02
class mathod  (0) 2019.10.02
method문 사용  (0) 2019.09.30
enum 문제  (0) 2019.09.27
두수를 입력받아 변수에 담기  (0) 2019.09.26
:

백준 2438번 문제

Console(콘솔)/알고리즘 2019. 9. 30. 17:15

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace Syntax15

{

    class Program

    {

        static void Main(string[] args)

        {

            int input = int.Parse(Console.ReadLine());

            for(int i = 1; i <=input; i++)

            {

                for(int j = 0; j<i; j++)

                {

                    Console.Write("*");

                }

                Console.WriteLine();

            }

        }

    }

}

 

 

'Console(콘솔) > 알고리즘' 카테고리의 다른 글

백준 8393번  (0) 2019.09.30
백준 10430번  (0) 2019.09.27
백준 10869번  (0) 2019.09.27
백준 1008번  (0) 2019.09.27
백준 10998번  (0) 2019.09.27
: