Class 특강
Apple apple = new Apple();
// 이데아 세계(Class)에서 현재 세계(작업 공간)로 가져오는 작업
// 객체화, Instance화
Apple apple1 = new Apple();
Apple apple2 = apple1;
// 위와 같은 경우는 apple1과 apple2가 같은 주소값을 가지게 됨
// 예시 사과
class Apple
{
public int sweet = 5;
public float hardless = 2.0f;
public Color color = Color.Green;
public string name = "Aori";
public string productLocation = "An-dong";
// 위 데이터 더미들은 힙 메모리에 저장됨
public Apple(int _sweet, float _hardless, Color _color, string _name, string _productLocation)
{
sweet = _sweet;
hardless = _hardless;
color = _color;
name = _name;
productLocation = _productLocation;
}
public Apple(string _productLocation)
{
productLocation = _productLocation;
}
public Apple()
{
}
}
class FileName
{
static void Main()
{
Apple hongro = new Apple(6, 4.0f, Color.Red, "hongro", "Chengsong");
Apple aori = new Apple();
Apple choongju = new Apple("choongju");
}
}
// 예시 자전거 클래스 치환
class Bike
{
public string frame;
public int price;
public string factory;
public string company;
public Wheel frontwheel;
public Wheel rearwheel;
}
class Wheel()
{
public int size;
public Color color;
public Tire tire;
public string company;
}
아직은 다소 생소하고 어려운 부분이기에 지속적인 복습과 연습이 필요한 파트
항상 봐오던 정답 풀이 해설에서 이해가 안가던 부분이 약간은 이해가 되기 시작