C#프로그래밍 64

구조체 ,추상 클래스, 봉인, 인터페이스, vector2

App 클래스 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace LearnDotnet { internal class App { //생성자 메서드 public App() { //업캐스팅 IAttackable marine = new Marine(); marine.Attack(); //다운캐스팅 Marine m = (Marine)marine; m.StimPack(); } } } Marine 클래스 using System; using System.Collections.Generic; using System.Linq; using System..

C#프로그래밍 2023.07.24

업캐스팅과 다운캐스팅

App 클래스 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace LearnDotnet { internal class App { //생성자 메서드 public App() { //Marine marine = new Marine(); //테란유닛 // ↑ //마린 //업캐스팅 (암시적) TerranUnit unit = new Marine(); //marine 변수의 값은? //Marine클래스의 인스턴스 //타입은? //TerranUnit unit.Attack(); //스팀팩 사용하고싶으면 marine 변수의 타입 -> Marine으로 ..

C#프로그래밍 2023.07.24

virtual, override, overload, base

면접 무조건 물어봄 virtual, override, overload, base가 뭔지.. Marine 클래스 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace LearnDotnet { internal class Marine : TerranUnit { //멤버변수 //생성자메서드 public Marine() { Console.WriteLine("Marine클래스 생성자 호출됨"); Console.WriteLine(this.hp); } //멤버메서드 //파생클래스에서 override public override void Attack(..

C#프로그래밍 2023.07.24

저글링, 마린, 메딕

1. 저글링 클래스 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace LearnDotnet { internal class Zergling { //멤버변수 int hp; int damage; float moveSpeed; //생성자메서드 public Zergling(int hp, int damage, float moveSpeed) { this.hp = hp; this.damage = damage; this.moveSpeed = moveSpeed; Console.WriteLine("저글링이 생성되었습니다."); Console.Write..

C#프로그래밍 2023.07.24

플레이어, 몬스터, 무기[출력만, 입력포함]

Main 메서드 [공통] using System; namespace LearnDotnet { internal class Program { static void Main(string[] args) { new App(); //new: 인스턴스 호출[값이라 변수에 넣을 수 있음] } } } 1. App 클래스 [출력만] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static LearnDotnet.Weapon; namespace LearnDotnet { internal class App { //데이터 //생성자 public App() { ..

C#프로그래밍 2023.07.21

this , 매개변수 있는 메서드, 매개변수도 있고 반환값도 있는 메서드, 반환값만 있는 메서드, 메서드의 종류

Main 메서드 [공통] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Starcraft { internal class Program { static void Main(string[] args) { new App(); } } } 1. App 클래스 [this] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Starcraft { internal class..

C#프로그래밍 2023.07.21