전체 글
-
03/10 매개변수가 없고 반환값이 있는 메서드 정의 및 호출C#/수업내용 2021. 3. 11. 00:52
using System; namespace Study00 { class Program { enum eClass { GhostKnight, Fighter, Gunner, Mage } static void Main(string[] args) { //매개변수가 없고 반환값이 있는 메서드 정의 및 호출 Console.WriteLine("메서드 호출"); Console.WriteLine("반 인원수는 {0}명 입니다.", GetClassNumberOfPeople()); Console.WriteLine("소지 물약 갯수는 {0}개 입니다.", GetNumberOfPotions()); Console.WriteLine("원주율은 {0}입니다.", getPi()); Console.WriteLine("캐릭터의 전직은 {0..
-
03/10 매개변수가 있는 메서드 정의 및 호출C#/수업과제 2021. 3. 11. 00:35
using System; namespace Study00 { class Program { static void Main(string[] args) { //매개변수가 있는 메서드 정의 및 호출 Console.WriteLine("메서드를 호출"); Move("동"); Reload(30); Provoke("몬스터"); PickUp("복권"); WearEquipment("데파르망"); ReinforceItem("제스가텐"); ChargeTheBill(10000); Synthesize("언커먼아이템", "레어아이템"); Return("헨돈마이어"); Enter("그락카락"); } //이동한다 (방향) static private void Move(string direction) { Console.WriteLine(..
-
03/10 매개변수, 반환타입이 없는 메서드 정의 및 호출C#/수업과제 2021. 3. 11. 00:14
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study00 { class Program { static void Main(string[] args) { //매개변수, 반환타입이 없는 메서드 정의 및 호출 Console.WriteLine("메서드 호출"); AttackGoblin(); Die(); Revive(); UseSkill(); ShootGun(); Rest(); Sit(); UsePortal(); Sleep(); Save(); } //고블린 공격 static private void AttackGoblin() { Cons..
-
03/10 수업내용 메모C#/수업내용 2021. 3. 10. 18:23
2021/03/10 switch문 case에 블록을 사용하면 변수 선언에 이점이 있음 기능 : 메서드 메서드를 호출, 메서드의 기능을 사용함 반환타입 주석 단축키 : 컨트롤 + k -> c 주석 풀기 : 컨트롤 + k -> u 코드 정리 : 컨트롤 + k -> f 콘솔 창 색깔변경 메서드 문을 포함하는 코드 블럭, 메서드의 이름은 동사로 시작, 대문자로 시작 메서드 호출은 메서드의 기능을 사용한다는 것 메서드 작성 절차, 기능생각 -> 정의 ->구현 접근지정자(private, public) private는 클래스 내부에서만 접근 가능 static은 static끼리만 호출 가능, 메모리에 하나만 잡혀있음 메서드 콜 스택(Method Call Stack) 스택 프레임 매개변수 랩핑
-
WriteLine()메서드 연습 7C#/수업내용 2021. 3. 10. 15:44
using System; namespace Study00 { class Program { static void Main(string[] args) { Console.WriteLine("방향을 입력해주세요. 입력 예 : 동, 서, 남, 북"); string direction = Console.ReadLine(); Move(direction); Console.Read(); } //동쪽으로 이동 static private void Move(string direction) { switch(direction) { case "동": Console.WriteLine("{0}쪽으로 이동했습니다", direction); break; case "서": Console.WriteLine("{0}쪽으로 이동했습니다", dire..
-
WriteLine()메서드 연습 6C#/수업내용 2021. 3. 10. 14:46
using System; namespace Study00 { class Program { static void Main(string[] args) { //입력받은 문자열 값(숫자)를 정수로 변환 //변환된 정수의 구구단 단수를 출력 //ex) //입력 값 "2" //변환 값 2 //출력 //2 * 1 = 2 //2 * 2 = 4 //2 * 3 = 6 //2 * 4 = 8 //... //2 * 9 = 18 int tmp = 0; Console.WriteLine("*****************************************************"); Console.WriteLine("출력할 구구단의 단수를 입력해주세요. 입력범위 : 2 ~ 9"); while(true) { tmp = Conve..
-
WriteLine()메서드 연습 5C#/수업내용 2021. 3. 10. 13:09
using System; namespace Study00 { class Program { static void Main(string[] args) { //입력받습니다. //정수로 변환 //입력 받습니다. //정수로 변환 //두 정수의 합을 출력 하세요 //정수의 범위 (-100 ~ 100) //출력 결과 //a : 10 //b : -2 //sum : 8 while(true) { int a = 0; int b = 0; int sum = 0; Console.WriteLine("******************************************************"); Console.WriteLine("두 정수의 합을 출력합니다. 정수 입력 범위 (-100 ~ 100)"); while (true) ..
-
WriteLine()메서드 연습 4C#/수업내용 2021. 3. 10. 12:49
using System; namespace Study00 { enum eTribe { Terran, Protoss, Zerg } class Program { static void Main(string[] args) { //Enum을 정의 합니다. //Terran, Protoss, Zerg //입력을 받습니다. //입력값을 숫자로 변환 합니다. //변환된 정수값을 Enum형식으로 변환 합니다. //선택문을 통해 선택한 종족을 출력 합니다. //출력결과 //Terran을 선택했습니다. int tmp = 0; eTribe tribe; Console.WriteLine("숫자를 입력해주세요. 입력예시 Terran : 0, Protoss : 1, Zerg : 2"); tmp = Convert.ToInt32(Cons..