using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study10 { class App { //2.대리자정의 : 클래스안에다 한다. //주의사항 : 대리자 인스턴스에 연결한(할당할) 메서드의 시그니처와 동일해야한다. //메서드 정의부터 한 뒤 대리자 생성 delegate int MyDelegate(int a, int b); //생성자 public App() { //3. 변수정의 MyDelegate del; //3. 대리자 인스턴스화 del = new MyDelegate(Plus); //5. 대리자 호출 :대리자의 메서드 호출 int ..
using System; using System.Collections; using System.Collections.Generic; namespace Study10 { class App { //생성자 public App() { //문자형식(Char) 변수 a를 정의 char a; //값을 할당할땐 작은 따옴표로 할당'' a = 'a'; //변수의 값을 출력 Console.WriteLine(a); Console.WriteLine(a++); //65+1 Console.WriteLine(a + 1); Console.WriteLine(a - 1); Console.WriteLine(a--); //문자 형식은 정수로 암시적 변환 가능 int b = (int)a; //명시적 int c = a; //암시적 string..
App 클래스 using System; using System.Collections; using System.Collections.Generic; namespace Study09 { class App { public App() { Inventory inven = new Inventory(5); inven.AddItem(new Weapon("장검")); inven.AddItem(new Weapon("장검")); inven.AddItem(new Weapon("단검")); inven.AddItem(new Weapon("창")); inven.AddItem(new Weapon("단검")); Console.WriteLine(inven.Count); inven.PrintAllItems(); //장검 x 2 //단검 ..
App단 using System; using System.Collections; using System.Collections.Generic; namespace Study09 { class App { public App() { Marine marine = new Marine(); Firebat firebat = new Firebat(); marine.Attack(); firebat.Attack(); } } } 테란 유닛 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study09 { class TerranUnit { //생성자 p..
using System; using System.Collections; using System.Collections.Generic; namespace Study09 { class App { public App() { //Qeueu인스턴스 생성 Queue q = new Queue(); //Add q.Enqueue(1); q.Enqueue(2); q.Enqueue(3); //contains bool contains = q.Contains(3); Console.WriteLine(contains); //단일 요소 가져오기 int peek = q.Peek(); //확인 Console.WriteLine(peek); int num = q.Dequeue(); //제거 Remove Console.WriteLine(num..
using System; using System.Collections; using System.Collections.Generic; namespace Study09 { class App { public App() { Console.WriteLine("App생성자 입니다."); //list 인스턴스 생성 List armors = new List(); Armor armor0 = new Armor("투구"); Armor armor1 = new Armor("갑옷"); Armor armor2 = new Armor("어깨 방어구"); Armor armor3 = new Armor("무릎 방어구"); //Add armors.Add(armor0); armors.Add(armor1); armors.Add(armor2); ..
ArrayList using System; using System.Collections; namespace Study09 { class App { ArrayList list; //변수 정의 //생성자 public App() { Console.WriteLine(); //모든 컬렉션을 사용하기 위해서는 //먼저 인스턴스를 생성해야 한다 list = new ArrayList(); //인스턴스를 반드시 생성하자 list.Add("홍길동"); //추가 list.Add(1); //1 -> object list.Add(true); list.Add(new Hero()); string name = list[0].ToString(); Console.WriteLine(name); int num = (int)list[1]; ..