[4기 - 배준일] 1~2주차 과제: 계산기 구현 미션 제출합니다.#187
Open
bjo6300 wants to merge 17 commits intoprgrms-be-devcourse:bjo6300from
Open
[4기 - 배준일] 1~2주차 과제: 계산기 구현 미션 제출합니다.#187bjo6300 wants to merge 17 commits intoprgrms-be-devcourse:bjo6300from
bjo6300 wants to merge 17 commits intoprgrms-be-devcourse:bjo6300from
Conversation
함수 실행 범위를 생각해보니 같은 클래스 내에서 사용되어서 동기화를 생각하지 않아도 될 것 같다.
Hunkik
reviewed
Jun 15, 2023
Hunkik
left a comment
There was a problem hiding this comment.
- 객체지향적 설계는 함부로 말씀드리긴 힘들지만 History를 인터페이스로 짠다던가, Menu를 분리한다던가, 있을 수 있겠네요. 또 showHistory도 결국 출력인데 output을 하는곳에서는 모두 output으로 관리해서 di를 받는것도 괜찮아보이구요!
- 역할과 책임 부분은 제가 말한것 좀 더 생각하시면 될것같습니다. 제가 뭔가 말씀드리기 애매하네여..
Comment on lines
+7
to
+17
| private static int getPriority(char operator) { | ||
| switch (operator) { | ||
| case '+': | ||
| case '-': | ||
| return 1; | ||
| case '*': | ||
| case '/': | ||
| return 2; | ||
| } | ||
| return -1; | ||
| } |
There was a problem hiding this comment.
우선순위는 Operator Enum에 있어도 될것같아여, 내부 변수라던가 활용하면 좋겠네요!
| import com.programmers.engine.io.Output; | ||
| import java.util.Scanner; | ||
|
|
||
| public class Menu implements Input, Output { |
There was a problem hiding this comment.
Menu를 다중 상속으로 구현체로 쓴다면, 나중에 Input이나 Output중에 각각 따로 바뀌는경우에는 따로 빼시는건가요? 예를들면 Output은 file로 출력하거나 하는 경우가 있겠네요.
Member
Author
There was a problem hiding this comment.
메뉴가 두 가지 책임을 가지고 있어보이네요..! 고민해서 분리해보겠습니다.
Comment on lines
+15
to
+18
| private final Input input; | ||
| private final Output output; | ||
| private final CalculationFormula calculationFormula; | ||
| private final Menu menu; |
There was a problem hiding this comment.
interface를 썼는데 굳이 Menu를 또 받는 이유가 궁금합니다.
|
|
||
| import java.util.Stack; | ||
|
|
||
| public class InfixToPostfix { |
Member
Author
There was a problem hiding this comment.
다시 생각해보니 static을 사용할 이유가 없어보입니다. 수정하겠습니다!
Comment on lines
+14
to
+24
| if (ch == ' ') { | ||
| continue; | ||
| } | ||
|
|
||
| if (isDigit(ch)) { | ||
| operandStack.push((double) (ch - '0')); | ||
| } else { | ||
| Operator operator = Operator.fromSymbol(ch); | ||
| double rightOperand = operandStack.pop(); | ||
| double leftOperand = operandStack.pop(); | ||
| double result = operator.calculate(leftOperand, rightOperand); |
There was a problem hiding this comment.
ch를 통해서 validation 했다면 switch도 좋아보이네요.� 하지만 수정은 하실필요없습니다. switch쓰는게 java에서는 안쓰는곳도 많은걸로알고있어서..
|
고생하셨습니다.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 과제 설명
👩💻 요구 사항과 구현 내용
feat : I/O 구현, Menu 구성
전체적인 흐름을 파악하고 틀을 잡았습니다.
feat : 계산식 입력 받기
Input, Output 인터페이스를 만들고 Menu 클래스를 만들어 Input, Output을 상속받았습니다. 상속받은 인터페이스를 통해 계산식을 입력받고 공백을 제거했습니다.
feat : 중위 표기식을 후위 표기식으로 변환
입력받은 중위 표기식을 후위 표기식으로 변환하는 함수를 추가했습니다.
feat : 후위 표기식 계산 및 출력
변환된 후위 표기식을 계산하고 결과를 출력했습니다.
feat : 조회 기능 구현
Map<Integer, String>을 구현해서 인덱스를 키 값, 입력받은 수식을 value로 지정했습니다. 그리고 이 Map에 데이터를 저장하고 조회하는 기능을 구현했습니다.
style : 코드 컨벤션 정리
이해하기 수월하게 함수 명과 변수 명을 수정했습니다.
feat : 함수 모듈화
while문의 조건이 길어서 모듈화 시켰습니다.
feat : 명확한 case 분리
변수 할당으로 이름 지어서 가독성을 향상시켰습니다.
✅ 피드백 반영사항
✅ PR 포인트 & 궁금한 점
(테스트 코드는 마감 기한 내에 빠르게 작성하겠습니다..!)