자바 과제(계산기) && 깃허브 초기 설정

최길중·2026년 1월 9일

깃허브 저장소 만들기

과제에 앞서 먼저 저장소 만들어서 복습겸 자꾸 해보기
남들이 볼 수 있으니 비계로...봐도 상관 없다만...그냥...

인텔리제이 터미널 명령어 작성한거 순서대로 메모
git init
git status 빨간색 확인
git remote add origin https://github.com/cgj8228/calculator-project.git 깃허브 연결
git remote -v
git add .
git commit -m "(수정된 내용 보내기)"
git commit -m "프로젝트 초기 세팅 및 Main 클래스 생성"
git branch -M main
git push -u origin main

git add src/step2: 이건 실수로 전부 push 해서 다시작성
또는 파일 하나만이면
git add src/step2/Calculator.java

git commit -m "step2 제출"
git push


계산기 만들다 질문을 통해 해결한 문제 BF, AF로 정리
1)calculate() 역할
-BF: calculate() 안에서 저장까지 함
arryList.add(result);
-AF: calculate()는 계산만 하고 저장 안 함
return result;

2)Setter
-BF: 리스트 통째로 교체 + return까지 함(캡슐화 깨짐)
public List setArryList(List arryList) {
return this.arryList = arryList;
}
-AF: 결과 1개만 추가, void(정상)
public void setArryList(int result) {
arryList.add(result);
}

3)main()에서 리스트 생성
-BF: main에서 쓸데없이 새 리스트 만듦
List arryList = new ArrayList<>();
-AF: main에서 리스트 생성 제거
(삭제)

4)main()에서 저장 호출 방식
-BF: setArryList(arryList)로 리스트를 꽂아넣음(이상함)
System.out.println(calculator.setArryList(arryList));
-AF: 계산 결과를 저장 메서드로 1번만 추가
calculator.setArryList(result);

5)출력 방식
-BF: setter를 출력용으로 사용함(목적 틀림)
System.out.println("Set: " + calculator.setArryList(arryList));
-AF: 저장은 set, 확인은 get으로 분리
System.out.println("Get: " + calculator.getArryList());

결론
-BF: 계산+저장 섞임 + 외부 리스트로 내부 리스트 교체(캡슐화 깨짐)
-AF: calculate=계산만, set=저장만, get=조회만(캡슐화 유지)


홍순구 튜터님께 질문을 처음 해봤다.
엄청 잘 답해 주셔서 도움이 많이 됐다.
슥슥 보시더니 문제점을 빠박!! 찾으시는 게 신기했다. 인공지능인 줄...

profile
개발자가 되고 싶어요

0개의 댓글