본문 바로가기

KDT/C# 프로그래밍50

23/07/26 가짜 인벤토리 만들기1 아이템 클래스 using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading.Tasks; namespace starcraft { internal class Item { public ItemData data; //생성자 public Item(ItemData data) { this.data = data; } //아이템 데이터의 이름을 반환하는 메서드 public string GetName() { //반환값 return this.data.name; } } } 아이템데이터 클래스 usin.. 2023. 7. 26.
23/07/25 배열 복습 및 연습(집에서) ※헷갈렸던 부분※ 1. 배열 선언, 배열의 요소에 데이터 담기,배열 초기화 2. 2차원 배열 전체적인 과정!! 1. 배열 기초 지식 연습 // 정수 배열을 선언 후 배열 요소에 데이터 담기 (배열 용량: 3) ▶배열 선언 int[ ] arr = new int[3]; ▶배열 요소에 데이터 담기 ('[ ]'안에 있는 것은 인덱스) arr[0] = 1; arr[1] = 2; arr[2] = 3; ------------------------------------------ ▶배열 초기화 (방법: 3개) 방법 1) int[ ] arr = new int[3] {1,2,3}; 방법 2) int[ ] arr = new int[ ] {1,2,3}; 방법 3) int[ ] arr = {1,2,3}; 2. 2차원 배열 전체.. 2023. 7. 25.
23/07/25 다차원 배열 기초연습 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace starcraft { internal class App { //생성자 public App() { //정수형 2차원 배열 정의 및 배열의 인스턴스 생성 int[,] map = new int[3, 2]; //인덱스로 배열의 요소에 접근 map[2, 1] = 1; //배열의 순회 (요소를 출력) int rowLength = map.GetLength(0); int colLength = map.GetLength(1); //맵을 출력 for(int i = 0; i < rowLength; i++.. 2023. 7. 25.
23/07/25 다차원 배열2 using Starcraft; using Starcraft; using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Net.Mail; using System.Runtime.Serialization.Formatters; using System.Text; using System.Threading.Tasks; namespace Starcraft { internal class App { int[,] playerMap; int rowIdx; int colIdx; //생성자 public App() { int[,] map = { {1.. 2023. 7. 25.
23/07/25 다차원배열 using starcraft; using Starcraft; using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Net.Mail; using System.Runtime.Serialization.Formatters; using System.Text; using System.Threading.Tasks; namespace Starcraft { internal class App { //생성자 public App() { //배열의 인스턴스화 int[] arr = new int[3]; //3:length int[] arr2 =.. 2023. 7. 25.
23/07/25 인벤토리 (아이템 찾고 빼기) 복습 (복습 내용) 0. 장검 1. 단검 2. 활 3. [ ] 4. [ ] -------------------------------- 찾을 아이템: 장검 아이템 이름: 장검, 찾는 이름: 장검 찾았다!: 장검 -------------------------------- 0. [ ] 1. 단검 2. 활 3. [ ] 4. [ ] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Starcraft { internal class Item { public string name; //생성자 public Item(string name) { this.n.. 2023. 7. 25.