C# (72) 썸네일형 리스트형 반환값이 있는 메서드 연습 (벌쳐, 템플러, 홀짝 판단, 줄넘기) 1. 벌쳐 마인설치 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloWorld { class Program { const int MAX = 3; static int mineCount = 3; static void Main(string[] args) { for (int i = 0; i 0) { mineCount--; Console.WriteLine("설치했습.. 메서드와 지역변수, 전역변수 복습 1.다이아몬드와 소환권 구매 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloWorld { class Program { static int gold; static int diamondCount; static int summonTicketCount; static void Main(string[] args) { gold = 1000; diamondCount = 0; summonTicketCount = 0; Purchase("다이아몬드"); Purchase("다이아몬드"); Purchase("다이아몬드"); Purchase(".. 반환값은 없고 매개변수가 있는 메서드 연습 1. ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ 2. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloWorld { class Program { static void Main(string[] args) { //호출 Purchase("물약", 5); } //기능 : {0}을 n번 구매합니다 //정의 static void Purchase(string Goods, int n) { for (int i = 0; i < n; i++) { Console.WriteLine("{0}을.. 반환값이 없고 매개변수가 있는 메서드 정의 및 호출 들여쓰기 수정 완료 매개변수가 1개인 메서드 3개 1. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloWorld { class Program { static void Main(string[] args) { //호출 UseSkill(3); } //정의 static void UseSkill(int n) { for (int i = 0; i < n; i++) { Console.WriteLine("스킬을 사용합니다."); } } } } ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ.. 메서드 정의하고 호출하기 5번연습 1. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloWorld { class Program { static void Main(string[] args) { //호출 AttackMonster(); } //기능: 몬스터를 공격합니다. //정의 static void AttackMonster() { Console.WriteLine("몬스터를 공격합니다."); } } } ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ 2. using System; using System.Colle.. ReadKey()와 ConsoleKeyInfo 그리고 if문 1.목표 - 엔터 필요없이 하나의 키로만 입력 받아 각각 다른 문구 출력하기 (숫자) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloWorld { class Program { static void Main(string[] args) { Console.WriteLine("1. 공격 2. 스킬 3. 도망"); ConsoleKey input = Console.ReadKey().Key; Console.WriteLine(); char keyChar = (char)input; if (keyChar == '1') { Console... for문 연습문제 복습 8. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloWorld { class Program { static void Main(string[] args) { int startTime = 9; for (int i = 0; i < 8; i++) { int time = i + 1; Console.WriteLine("{0}교시 {1}:30 ~ ", time, startTime); if (time == 4) { startTime += 2; } else { startTime++; } } } } } 변수선언에 익숙해지기 위해서 참고해.. if문, if-else문 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloWorld { class Program { static void Main(string[] args) { //아이디를 입력하세요 : hong //비밀번호를 입력하세요 : 123456 //비밀번호를 다시 입력하세요 : 12345 //비밀번호가 틀렸습니다. //종료 //아이디를 입력하세요 : hong //비밀번호를 입력하세요 :123456 //비밀번호를 다시 입력하세요 : 123456 //hong님 환영합니다 //종료 Console.Write("아이디를 입력하세요 : "); st.. 논리연산자 복습 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloWorld { class Program { static void Main(string[] args) { //논리연산자 //AND : && //A && B : A,B 둘다 True면 True //bool result = true && true; True //bool result = true && false; false Console.Write("입력 1 (true, false) : "); string input1 = Console.ReadLine(); Console.Write.. 삼일째 수업 복습 1. 입력받기 - ReadLine을 이용해서 입력을 받고 입력받은것을 출력하기 2. ReadKey(), ConsoleKeyInfo타입, ConsoleKey.. 또는 출력목표값을 미리 변환하는 변수를 선언하여 추가 변수를 이용하는 방법 변환할땐 캐스트 연산자()가 아닌 Convert.Toint32()를 써도 무방. ConsoleKeyInfo타입의 값에는 Key와 KeyChar있다 Key는 열거형식(ConsoleKey)의 값이고 KeyChar는 char타입의 값이다 ----------------------------------------------------------------------------------------------------------------------------------- 3.산술,.. 이전 1 ··· 3 4 5 6 7 8 다음