본문 바로가기

C#

(72)
람다식 연습 3 (Action) - 빵만들기 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloWorld { class App { //생성자 public App() { string[] ingredient = { "물", "우유", "설탕", "소금", "강력분", "이스트", "버터" }; this.Cook(ingredient, (bread) => { Console.WriteLine(bread); //Bread (인스턴스) }); /* * Cook메서드가 출력하는거... * 물, 우유, 설탕, 소금, 강력분, 이스트, 버터 * 넣고 반죽을 합니다. * 오븐에 넣고 기..
람다식 연습2 (Action) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloWorld { class App { //생성자 public App() { this.LoadDatas(() => { Console.WriteLine("loaded all datas...!!!"); }); } void LoadDatas(Action action) { action(); } } }
대리자연습8 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloWorld { class App { //1.대리자 정의 public delegate void Del(int id); //생성자 public App() { //SCV클래스를 만든다. SCV scv = new SCV(100); //SCV클래스에 Build메서드를 만든다. scv.Build(this.BuildCompleteHandler);//4. 대리자 변수에 메서드 연결 (인수) } //3. 연결할 메서드 정의 void BuildCompleteHandler(int id) { C..
대리자연습6 고블린 (오류수정) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloWorld { class App { public delegate void Del(); Goblin goblin; //생성자 public App() { this.goblin = new Goblin(); goblin.onAttackComplete = this.OnAttackComplete; goblin.ChangeState(Goblin.eState.Idle); goblin.GetState(this.goblin); goblin.ChangeState(Goblin.eState.Att..
대리자연습6 고블린 (오류) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloWorld { class App { public delegate void Del(); Goblin goblin; //생성자 public App() { this.goblin = new Goblin(); goblin.onAttackComplete = this.OnAttackComplete; goblin.ChangeState(Goblin.eState.Idle); goblin.ChangeState(Goblin.eState.Attack); goblin.GetState(this.gob..
대리자 연습 5 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloWorld { class App { UI ui; Hud hud; //1.대리자 선언 public delegate void Del(float per); //생성자 public App() { this.ui = new UI(); this.hud = new Hud(); Hero hero = new Hero(20); //max hp hero.StepOnTrap(3, this.StepOnTrapHandler); //trap damage } //2. 연결할 메서드 정의 private v..
대리자 연습4 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloWorld { class App { //1.대리자 선언 public delegate void Del(Weapon weapon); //생성자 public App() { Blacksmith blacksmith = new Blacksmith(); //3.변수선언하고 넣기 (연결) Del handler = CreateWeaponHandler; blacksmith.CreateWeapon("장검", this.CreateWeaponHandler); } //2. 연결할 메서드 정의 voi..
대리자 연습 3 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloWorld { class App { public delegate void Del(string animeName); //생성자 public App() { Hero hero = new Hero(); hero.onComplete = this.OnHeroAnimationComplete; hero.PlayAnimation("Idle"); } void OnHeroAnimationComplete(string animeName) { Console.WriteLine(animeName); }..
대리자 연습 2 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloWorld { class App { //1 대리자 선언 public delegate void Del(); //생성자 public App() { Button btn = new Button(); //3-2. 대리자 초기화 btn.onclick = this.OnClick; btn.Click(); } //2 대리자에 연결될 메서드 void OnClick() { Console.WriteLine("Click"); } } } using System; using System.Collect..
OX퀴즈 using System; class App { int sum; public App() { while(true) { Console.Write("input: "); string input = Console.ReadLine(); Console.WriteLine(); for (int i = 0; i < input.Length; i++) { Console.Write(input[i]); } Console.WriteLine(); for (int i = 0; i < input.Length; i++) { if (input[i] == 'o' || input[i] == 'O') { sum++; Console.Write("{0}점", sum); } else { sum = 0; Console.WriteLine(); } } Co..