kotlin class, objects simple explanation 코틀린 클래스, 오브젝트, 매서드, 프로퍼티 이론 설명 예시
2022. 5. 17. 16:49ㆍ카테고리 없음
1. class
main function has variables and other functions
class has properties and methods.
>>similar with..
variables ~ properties
functions ~ methods
2. objects
product made by components of class
예시
1) 차 클래스
(1) properties
- int 바퀴 개수
- int 문 개수
- bool 트렁크 여부
(2) methods
- 멈추는 기능
- 자율주행기능
- 후진하는 기능
- 전진하는 기능
(3) objects
버스 object는 바퀴 4개, 문 20개, 트렁크 있음
오토바이 object는 바퀴 2개, 문 0개, 트렁크 없음
자동차 object는 바퀴 4개, 문 4개, 트렁크 있음
즉, 차 클래스의 properties 와 methods 로 objects 를 원하는만큼 만들 수 있음.
2) 인간 클래스
(1) properties
-int 키
-String 성별
(2) methods
-밥먹기
-춤추기
-자기
(3)objects
julian은 키 170, 남자 인간으로 밥먹고 춤추고 잠.