c#_DAY5_retrospective_0902

Heejin Jo·2021년 9월 2일
0

Unity_C#

목록 보기
11/16

계속 반복반복반복

public class Class1
{
	//code를 짠다는건? 
	//변수와 함수들을 짜고 호출해서 하나의 콘텐츠가 동작하도록 만드는 과정이야


	//box를 그린다고 하면??
	void drawBox(float x, float y, float width, float height)
    {
		Debug.Log($"박스 그리기: x : {x}, y : {y}, width : {width}, height : {height}");
    }

	void Start()
    {

		DrawBox(10, 10, 100, 100);
    }
}

	void drawBox(float x, float y, float width = 100, float height = 100) //기본값을 필수적인 매개변수를 선언할 수 있는데
    {
		Debug.Log($"박스 그리기: x : {x}, y : {y}, width : {width}, height : {height}");
    }

	void Start()
    {

		DrawBox(10, 10, 100, 100);
		drawBox(10, 10, 100); // 이렇게 되면 매개변수는 순.서.대.로 구분한단다.
                              // 기본값은 항상 뒷쪽에 있는 매개변수만 넣을수 있어
    }

//함수라는 게 결국, 메서드라는 게 결국 
    //코드 집합, 내가 하고 싶은 걸 가능하게 만들기 위한
    //이번엔 함수 안에 함수를 만들어보자

	void drawBox(float x, float y, float width = 100, float height = 100)
    {
        drawBox(x, y, x + width, y);

		void drawBox(float fromX, float fromY, float toX, float toY)
        {
            Debug.Log($"{fromX}:{fromY} 에서 {toX}, {toY}로 선 그리기");
        }
    }

public class Car
{
    var speed = 0;
    var engine = 0;

   public string Car()
    {
        Carinfo = $"{speed}이고 {engine}"
        return Carinfo
    }


    //아래는 사실 다른 메인 클래스에서 부를 때 쓸 거
	void Start()
    {
        Car car = new Car();
        string carinfo = car.carinfo();
    }


}
profile
core를 기르자

0개의 댓글