C#

C#/수업 내용

2023.01.10 오전 수업내용 : 프로퍼티

영웅 클래스의 아이디에 값을 할당하는 세가지 방법. App 클래스 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study09 { class App { //생성자 public App() { Console.WriteLine("App생성자 입니다."); //방법1 //맴버변수 id의 한정자는 private //객체를 초기화 //Hero hero = new Hero(100); //방법 2 //맴버변수 id 한정자는 public //Hero hero = new Hero(); //hero.id = 100; //방법 3 //Hero her..

C#/수업 과제

인벤토리 만들기 (클래스 배열 이용)

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study08 { class Inventory { private int capacity; //최대 용량 private Item[] items; //아이템들을 관리 배열 int index; //생성자 public Inventory(int capacity) { this.capacity = capacity; //배열 초기화 this.items = new Item[this.capacity]; } public void AddItem(Item item) { for (int i = 0; i < ..

C#/수업 내용

오전 : 2차원 배열 기본

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study07 { class App { //생성자 public App() { //2차원의 길이가 2이고 1차원의 길이가 3인 정수형 배열을 생성 int[,] arr; //2차원 배열 변수 정의 arr = new int[2, 3]; //arr[2차원의 인덱스, 1차원의 인덱스] //arr[0, 2] = 10; //------------ // 0 | 0 | 10| //------------ // 0 | 0 | 0 | //------------ //arr[2차원의 인덱스, 1차원의 인덱스..

C#/문제 해결

배열 안의 최대값 구하기

내가 짠 코드 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study07 { class App { //생성자 public App() { //최대값 구하기 int[] arrs = { 20, 10, 35, 30, 7 }; for (int i =0; i test) { test = arrs[i]; Console.WriteLine(test); } } //출력 //35 } } 최소값 구하기 for문 밖으로 변수 출력시키기 using System; using System.Collections.Generic; using System.Linq..

C#/수업 내용

배열 안에 있는 개수 세기

내가한 방식 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study07 { class App { //생성자 public App() { int[] numbers = { 1, 3, 1, 3, 2, 3, 1, 4, 4, 5 }; Console.WriteLine("배열에서 찾아서 세고 싶은 숫자를 입력하세요"); string inputnum = Console.ReadLine(); int input = Convert.ToInt32(inputnum); int count = 0; foreach (int num in numbers) { if..

C#/문제 해결

학생들 관리하는 방법(클래스 배열 사용)

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study07 { class Students { string[] names = { "김동준", "이환국", "홍길동", "재갈량", "조조" }; int[] ids = { 20230109, 20230110, 20230111, 20230112, 20230113 }; int[] scores = { 100, 90, 56, 75, 11 }; //생성자 public Students() { } public void StudentsList() { foreach (string name in nam..

C#/수업 내용

2023.01.09 오전 배열 복습

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study07 { class App { //생성자 public App() { Console.WriteLine("App 생성자."); //길이가 5개인 배열을 생성하고 모든 요소의 값을 -1로 초기화하세요 //같은 타입의 연속된 데이터들을 그룹하하고 관리하기 위함 - 배열의 사용 목적 //점수를 관리하기위해 배열을 사용했을때 int[] scores = new int[5]; //int[] scores = { -1, -1, -1, -1, -1 };// new int[5]; //scores..

C#/수업 내용

1차원 배열 수업내용

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study06 { class App { public App() { Console.WriteLine("App 생성자 입니다."); //배열 //연속된 같은 데이터를 관리할수 있는 공간 //배열 변수 정의 //타입[] 변수명 //정수형 테이터들을 저장하고 싶다면 int[] scores; //배열 인스턴스를 생성 //생성된 배열은 반드시 할당을 해주어야 한다. scores = new int[5]; //배열 초기화 //배열의 요소(변수) 인덱스 0~...배열의 용량 -1 //인덱스로 접근이..

C#/수업 내용

코인획득 (클래스 반환 이용)

app단 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study06 { class App { public App() { Console.WriteLine("App 생성자 입니다."); Hero hero = new Hero(); Monster monster = new Monster(); Coin coin = monster.Die(); monster = null; hero.Get(coin); Console.WriteLine(monster); } } } 코인 using System; using System.Collections.Gen..

C#/수업 과제

Class 메서드를 이용한 스타크래프트 유닛 인스턴스 만들기

App단 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study04 { class App { //생성자 public App() { //시나리오 1 : 드론이 광물이 바닥날때까지 캔다 (광물 자원 -5) Drone dorne0 = new Drone("드론1호",40,5, 2.344f); Mine mine = new Mine(100); dorne0.Mining(dorne0); for(int i = 0;i 0) { dorne0.Hit(dorne0, ghost0); } } } } } 고스트 고스트 --------- 체력 : 40 공격..

Bueong_E
'C#' 카테고리의 글 목록 (5 Page)