[JAVA] Lab Review (1,2)
2022.01.28
# Lab 1 - 클래스, 인스턴트 생성
Q)
(1) Matching 클래스 만들기
attributes - String firstWord / String secondWord / Int count
(2) constructors와 method 생성하기
- private void match() method : firstWord와 secondWord에 담긴 공통 글자수 세기, count attribute 수정
이 method는 모든 constructors에서 부를 수 있어야 한다.
- default constructor : firstWord&secondWord = null / count = 0 로 세팅한다
- copy constructor
- constructor : 3 arguments를 가지고 그에 맞는 parameters을 패스한다.
- Mutator and accessor methods
- equals() method
- toString() method
---------------------------------------
A)
(1) Matching 클래스 만들기
(2) constructors와 method 생성하기
- private void match() method : firstWord와 secondWord에 담긴 공통 글자수 세기, count attribute 수정
이 method는 모든 constructors에서 부를 수 있어야 한다.
- default constructor : firstWord&secondWord = null / count = 0 로 세팅한다
- copy constructor
- constructor : 3 arguments를 가지고 그에 맞는 parameters을 패스한다.
- Mutator and accessor methods
- equals() method
- toString() method
- driver(instance설정 후 output)
*******
---> 아직 equals()로 객체를 비교하는 개념이 헷갈린다.
# Lab 2
Q)
(1) Sphere 클래스 생성
attributes - double radius
(2) constructors & method 생성
- default constructor: one parameter for radius r.
- copy constructor
- Mutator and accessor methods
- equals() method : return true if objects have the same radius.
- getArea() method : 구의 면적을 계산 ( Area = 4 * radius * radius * Math.PI )
- toString() method: return radius and the area of the object.
- Static getTotalArea() method : array of shperes를 인풋으로 받고, 전체 array안의 object의 총 면적을 계산한다.
- Driver method: three instances of the sphere class to demonstrate the correctness of implementation.
---------------------------------------
A)
(1) Sphere 클래스 생성
attributes - double radius
(2) constructors & method 생성
- default constructor: one parameter for radius r.
- copy constructor
- Mutator and accessor methods
- equals() method : return true if objects have the same radius.
- getArea() method : 구의 면적을 계산 ( Area = 4 * radius * radius * Math.PI )
- toString() method: return radius and the area of the object.
- Static getTotalArea() method : array of shperes를 인풋으로 받고, 전체 array안의 object의 총 면적을 계산한다.
- Driver method: three instances of the sphere class to demonstrate the correctness of implementation.