Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
2f8bb46
feat : 입출력 인터페이스
SW-H Jun 11, 2023
5a6deed
feat : 예외 처리 문구
SW-H Jun 11, 2023
c4c3e88
feat : 계산기 - main문/계산
SW-H Jun 11, 2023
e2dcb42
feat : 입출력 인터페이스 구현
SW-H Jun 11, 2023
bd3aee3
feat : 연산자 enum으로 관리
SW-H Jun 11, 2023
52a1300
feat : 사용자 메뉴 enum
SW-H Jun 11, 2023
ee4d032
docs : java버전 명시
SW-H Jun 11, 2023
842467d
docs : 미사용중인 종속 삭제
SW-H Jun 11, 2023
c9c80e0
refactor : 코드 중복 제거
SW-H Jun 11, 2023
25a513e
refactor : 메인 함수를 포함한 클래스 추가
SW-H Jun 11, 2023
6d94091
refactor : 불필요한 개행 삭제
SW-H Jun 11, 2023
4d764ca
feat : 수식
SW-H Jun 15, 2023
882c684
feat : 삭제
SW-H Jun 15, 2023
1a150a5
feat : input/outputView 주입, 선택 메뉴별 수행 메소드를 HashMap으로 분리
SW-H Jun 15, 2023
a3901a5
feat : 출력 관련 내용 CalculatorInputView -> CalculatorOutputView 이동
SW-H Jun 15, 2023
451742e
refactor
SW-H Jun 15, 2023
775466d
feat : 수식 입력시 Expression 클래스 반환
SW-H Jun 15, 2023
5e41f40
feat : 불필요한 문법요소 제거, 연산자 우선순위 비교 메소드(hasLowerPrecedence) 추가
SW-H Jun 15, 2023
2590e8c
feat : 계산 결과 출력을 위해 인자->Integer
SW-H Jun 15, 2023
6b66bc0
feat : 불필요한 Optional 삭제, 메뉴-Integer 대응하도록 수정
SW-H Jun 14, 2023
2f88ba9
feat : main 함수 별도 분리
SW-H Jun 15, 2023
f154103
feat : 계산 인자 -> Double 형으로 변환(나눗셈)
SW-H Jun 15, 2023
ddc919c
feat : 함수 매핑 HashMap 삭제
SW-H Jun 15, 2023
9b34581
feat : CalculatorInputView 내에서 출력 함수 호출 삭제
SW-H Jun 15, 2023
9b943b9
feat : 계산 결과 Integer -> Double(나눗셈)
SW-H Jun 15, 2023
c6c5a68
feat : 문자열 자르기
SW-H Jun 15, 2023
6d43a13
feat : 계산 인자 Integer -> Double (나눗셈)
SW-H Jun 15, 2023
97b393a
feat : 계산 인자 Integer -> Double (나눗셈)
SW-H Jun 15, 2023
84540a2
feat : main 함수
SW-H Jun 15, 2023
eeb3796
feat : 계산 로직 수정(후위연산식 변환없이 연산자 우선 순위에 따라 계산)
SW-H Jun 15, 2023
c37cdad
feat : 수식 내의 공백 제거, split
SW-H Jun 15, 2023
50cabb1
refactor : list 타입 ArrayList -> List
SW-H Jun 15, 2023
0ac007e
feat : 연산자 우선 순위 계산
SW-H Jun 15, 2023
8b4ec3a
refactor : 미사용 메소드 삭제
SW-H Jun 15, 2023
a3544d8
feat : 없는 메뉴선택시 처리 추가
SW-H Jun 15, 2023
ea158fe
feat : 메시지 출력 메소드
SW-H Jun 15, 2023
6f1519d
feat : 메시지 출력 메소드
SW-H Jun 15, 2023
7fe46d5
feat : 없는 메뉴 선택시 처리 방법 수정
SW-H Jun 15, 2023
aa52739
refactor
SW-H Jun 15, 2023
202ce5d
feat : 계산 로직 버그 수정
SW-H Jun 15, 2023
716fb12
feat : 입력된 수식 null인 경우 처리
SW-H Jun 15, 2023
c2351bd
feat : 입력된 수식 null인 경우 처리
SW-H Jun 15, 2023
1f42c10
feat : 입력된 수식이 빈 문자열인 경우 처리
SW-H Jun 15, 2023
358117c
feat : 계산 기록 저장을 위한 저장소 추가
SW-H Jun 15, 2023
f635ecb
feat : 계산 기록 저장을 위한 저장소 추가, 조회 기능
SW-H Jun 15, 2023
06b76d3
feat : 계산 기록 출력
SW-H Jun 15, 2023
84ff197
feat : 수식 getter
SW-H Jun 15, 2023
49675ef
feat : 계산 기록 저장을 위한 저장소 추가
SW-H Jun 15, 2023
62afa70
feat : 계산 기록 저장을 위한 저장소 인터페이스 추가
SW-H Jun 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ plugins {
group = 'co.programmers'
version = '1.0-SNAPSHOT'

repositories {
mavenCentral()
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}
}

dependencies {
testImplementation platform('org.junit:junit-bom:5.9.1')
testImplementation 'org.junit.jupiter:junit-jupiter'
repositories {
mavenCentral()
}

test {
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/co/programmers/application/Application.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package co.programmers.application;

import co.programmers.view.CalculatorInputView;
import co.programmers.view.CalculatorOutputView;
import co.programmers.view.InputView;
import co.programmers.view.OutputView;

public class Application {

public static void main(String[] args) {
InputView inputView = new CalculatorInputView();
OutputView outputView = new CalculatorOutputView();
Calculator calculator = new Calculator(inputView, outputView);
calculator.run();
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

마지막 라인이 빠져있네요

89 changes: 89 additions & 0 deletions src/main/java/co/programmers/application/Calculator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package co.programmers.application;

import co.programmers.domain.Operator;
import co.programmers.domain.UserMenu;
import co.programmers.view.InputView;
import co.programmers.view.OutputView;
import java.util.Stack;

public class Calculator {

private final InputView inputView;
private final OutputView outputView;

public Calculator(InputView inputView, OutputView outputView) {
this.inputView = inputView;
this.outputView = outputView;
}

public void run() {
while (true) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

무한 루프보다는 탈출 조건이 명시 되어 있는 편이 좋은 거 같아요

UserMenu userMenu = UserMenu.get(inputView.inputUserMenu());
switch (userMenu) {
case INQUIRY:
// 구현 예정
break;
case CALCULATE:
String expression = inputView.inputExpression();
Integer output = calculate(expression);
outputView.print(String.valueOf(output));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

valueOf 함수가 불필요하게 너무 반복되는 거 같아요.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outputView를 수정하도록 하겠습니다

break;
case TERMINATE:
return;
}
}
}

private Integer calculate(String input) {
char[] expression = input.toCharArray();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

입력 값이 아무 이상없이 들어올거라고 단정짓기에는 사용자의 입력이 너무 자유롭지 않을까요>

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validation 관련해 추가하겠습니다

Stack<Integer> Operands = new Stack<>();
Stack<Character> Operators = new Stack<>();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

계산을 매번 할 때마다 새로운 Stack을 만들게 되겠네요! 비효율적이지 않을까요?

for (int i = 0; i < expression.length; i++) {
if (Character.isWhitespace(expression[i])) {
continue;
}
if (Character.isDigit(expression[i])) {
StringBuffer operand = new StringBuffer();
while (i < expression.length && Character.isDigit(expression[i])) {
operand.append(expression[i++]);
}
i--;
Operands.push(Integer.parseInt(operand.toString()));
} else if (expression[i] == '(') {
Operators.push(expression[i]);
} else if (expression[i] == ')') {
evaluateOperators(Operands, Operators);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bracket은 후순위로 진행해주시면 될 것 같아요

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

우선은 삭제했습니다

} else {
while (!Operators.empty() && comparePriority(expression[i], Operators.peek())) {
Operands.push(Operator.calculate(
String.valueOf(Operators.pop()), Operands.pop(), Operands.pop()
));
}
Operators.push(expression[i]);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기능에 비해 로직이 너무 복잡한 것 같아요
너무 모든걸 한 번에 고려하기보단 하나씩 차근차근 접근해보는건 어떨까요?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 계산 관련 로직도 수정하고 그에 따라 메소드도 분리해보았습니다(Calculation 클래스 확인 부탁드려요).

}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

로직이 굉장히 복잡하고 요구사항과 강하게 결합되어 있어요.
만약 입력값으로 들어오는 형식이 바뀌게 된다면 어떻게 될까요?
알고리즘 문제처럼 접근하기 보다는 좀 더 역할과 책임을 나누는게 좋아보여요.
현재의 Calculator 클래스는 너무 규모가 커보여서, 실행 로직과 Input, Output과 연계를 담당하는 CalculatorApp과 계산을 직접적으로 담당하는 Calculator로 나눠보는 건 어떨까요?

추가적으로 객체지향 생활체조 원칙을 따라 2 depth 이상 코드를 들여쓰지 말고, else와 else if를 사용하지 않고 리팩토링 하면 좀 더 가독성 있는 코드를 짤 수 있을 것 같아요.

evaluateOperators(Operands, Operators);
return Operands.pop();
}

private void evaluateOperators(Stack<Integer> operands, Stack<Character> operators) {
while (!operators.empty() && (operators.peek() != '(')) {
Character operator = operators.pop();
Integer operand1 = operands.pop();
Integer operand2 = operands.pop();
int result = Operator.calculate(
String.valueOf(operator), operand1, operand2
);
operands.push(result);
}

if (!operators.empty()) {
operators.pop();
}
}

private boolean comparePriority(char operator1, char operator2) {
return Operator.getSymbol(String.valueOf(operator1)).getPriority() >=
Operator.getSymbol(String.valueOf(operator2)).getPriority();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

우선순위를 비교하는 책임은 Operator에 있어도 되지 않을까요?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Operator 내에도 우선순위(priority) 필드를 가져서 해당 값을 사용하는 로직을 변경하겠습니다..

}
}
60 changes: 60 additions & 0 deletions src/main/java/co/programmers/domain/Operator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package co.programmers.domain;

import co.programmers.exception.ExceptionMessage;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public enum Operator {
ADDITION("+", 2, (operand1, operand2) -> Integer.valueOf(
operand1 + operand2
)),
SUBTRACTION("-", 2, (operand1, operand2) -> Integer.valueOf(
operand2 - operand1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

인자값이 모두 Integer인데 Integer.valueOf를 사용하는 이유가 있을까요?

)),
MULTIPLICATION("*", 1, (operand1, operand2) -> Integer.valueOf(
operand1 * operand2
)),
DIVISION("/", 1, (operand1, operand2) -> {
if (operand2 == 0) {
throw new IllegalArgumentException(ExceptionMessage.DIVIDED_BY_ZERO);
}
return Integer.valueOf(operand1 / operand2);
}),
OPENED_PARENTHESIS("(", 3, (operand1, operand2) -> 0),
CLOSED_PARENTHESIS(")", 3, (operand1, operand2) -> 0);

private static final Map<String, Operator> operators =
Collections.unmodifiableMap(Stream.of(values())
.collect(Collectors.toMap(Operator::getSymbol, Function.identity())));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 Map의 쓰임새가 좀 더 명시적으로 표현 될 수 있으면 좋을 것 같아요.

private final String symbol;
private final int priority;
private final BiFunction<Integer, Integer, Integer> operation;

Operator(String symbol, int priority, BiFunction<Integer, Integer, Integer> operation) {
this.symbol = symbol;
this.priority = priority;
this.operation = operation;
}

public static Integer calculate(String operator, Integer operand1, Integer operand2) {
return getSymbol(operator).operation.apply(operand1, operand2);
}

public static Operator getSymbol(String operator) {
return Optional.ofNullable(operators.get(operator))
.orElseThrow(() -> new IllegalArgumentException(ExceptionMessage.INVALID_SYMBOL));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기서 굳이 optional 로 한 번 감싸줘야할까요?
optional을 효율적으로 쓰는 방법은 어떤게 있을까요?

Copy link
Author

@SW-H SW-H Jun 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

operators.get()함수의 반환값이 null이 될 수 있어서(입력한 operator 가 정의된 +,-,*,/에 해당되지 않는 다면) exception처리를 하기 위해 위처럼 작성 했습니다. 다만 Optional로도 감싸주고 exception도 날리는건 중복으로 처리하는 것 같아서 둘중에 하나로만 했어도 될 것 같습니다. 아래는 optional에 대해 제가 찾아보고 이해한 내용입니다.

Optional은 호출 하는 쪽에 '반환 값이 null일 수도 있다(반환할 결과값이 없다)' 라고 명시적으로 알려주는 역할을 가진 것으로 이해했습니다. 그러니까 메서드가 반환한 결과 값이 '없음'을 표현하고자 하는데 null을 반환하는 것은 에러를 유발하거나 해서는 안되는 행동으로 여겨지니 도입된 개념입니다. 호출하는 쪽에서 null 체크를 쉽게 할 수 있어 NullPointerException을 방지할 수 있습니다.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기는 잘 고민해보고 더 궁금한 내용이 있으면 언제든 말씀해주세요~

}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public static Operator getSymbol(String operator) {
return Optional.ofNullable(operators.get(operator))
.orElseThrow(() -> new IllegalArgumentException(ExceptionMessage.INVALID_SYMBOL));
}
public static Operator getOperator(String input) {
return Arrays.stream(Operator.values())
.filter(operator -> operator.symbol.equals(input))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException(ExceptionMessage.INVALID_SYMBOL));
}

이런 방법은 어떠신가요?


private String getSymbol() {
return symbol;
}

public int getPriority() {
return priority;
}
}
31 changes: 31 additions & 0 deletions src/main/java/co/programmers/domain/UserMenu.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package co.programmers.domain;

import java.util.Collections;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public enum UserMenu {
INQUIRY("1"),
CALCULATE("2"),
TERMINATE("3");

private static final Map<String, UserMenu> values =
Collections.unmodifiableMap(Stream.of(values())
.collect(Collectors.toMap(UserMenu::getValue, Function.identity())));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

values라는 이름은 해당 자료구조가 어떤 역할을 하는지 알아보기 어려워요.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위와 같은 이유로 삭제했습니다

private final String value;

UserMenu(String value) {
this.value = value;
}

public static UserMenu get(String input) {
return Optional.ofNullable(values.get(input)).orElse(TERMINATE);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

어떤 의도로 Optional을 사용하신 걸까요?
메소드 체이닝이 너무 많아 코드 가독성을 해치는 걸로 보여요


public String getValue() {
return value;
}
}
11 changes: 11 additions & 0 deletions src/main/java/co/programmers/exception/ExceptionMessage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package co.programmers.exception;

public class ExceptionMessage {

public static final String DIVIDED_BY_ZERO = "0으로 나눌 수 없습니다.";
public static final String INVALID_SYMBOL = "잘못된 연산 기호입니다.";
public static final String INVALID_INPUT = "잘못된 입력입니다";

private ExceptionMessage() {
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

메시지 관리를 하는 방법에는 어떤것들이 있을까요?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum을 사용해 에러코드와 함께 관리하거나 Exception 클래스를 상속받은 클래스를 구현할 수도 있을 것 같습니다. 다만 저는 개수가 그렇게 많지 않고 단순히 에러 메시지를 코드화하여 관리하기 위함이라 위와 같이 사용했습니다.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

개발하면서 그 어떤것도 확답을 내릴 수 없어요
단순한 계산기 하나에도 발생할 수 있는 에러는 굉장히 많고 그에 맞는 에러메시지도 다양하겠죠?

갑자기 변경 할 때 전체적인 구조가 흔들리는 것 보단 지금은 괜찮더라도 추후 변경을 고려하여 설계하는 연습도 필요해요

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추후 변경을 고려하여 설계하라는 점은 염두에 두겠습니다🤩

그런데 예외메시지만 관리한다는 관점에서 볼때 enum을 사용하는 것과 현재방법의 차이를 잘 모르겠습니다,, 그리고 Exception 클래스를 상속받은 사용자 정의 예외클래스를 구현하는 것은 현재 예외의 개수도 적고 표준예외로 충분히 표현 가능하다고 느껴지는데 과한 구현이지 않을까 싶어서 필요하다면 나중에 확장하면서 고려하면 되지않을까 싶은데... 어떨까요....?🥹

제가 놓치고 있는 부분이 있을까요?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 표준 예외만으로 충분히 표현 가능하다면 커스텀한 에러 메시지를 따로 관리 해야할까요?
  2. 구조가 달라지는걸 확장이라고 표현할 수 있을까요?
  3. 에러메시지를 관리하는게 enum 밖에 없을까요?
  4. static 을 어떻게 써야 효율적일까요?

제가 이 클래스를 작성했다고 생각해보면 당장 위 고민들이 떠오르네요
더 많은 고민거리들이 있겠지만 최소한 이정도는 스스로 답변을 내릴 수 있도록 고민해봐주세요

58 changes: 58 additions & 0 deletions src/main/java/co/programmers/view/CalculatorInputView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package co.programmers.view;

import co.programmers.exception.ExceptionMessage;
import co.programmers.domain.UserMenu;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;

public class CalculatorInputView implements InputView {

private static final Scanner SCANNER = new Scanner(System.in);
private static final Set<String> USER_MENU =
Arrays.stream(UserMenu.values())
.map(UserMenu::getValue)
.collect(Collectors.toSet());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UserMenu Enum이 있음에도 불구하고 Set을 사용하신 이유가 궁금해요.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InputView에서 UserMenu의 유효성을 검사하고 있는 부분이 좀 어색하게 보였어요.
해당 기능은 UserMenu가 담당해도 되지 않을까요?


public CalculatorInputView() {
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

빈생성자는 의도하신걸까요?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

빠뜨리고 수정한 것 같습니다. 삭제하겠습니다


public String inputUserMenu() {
printMenuChoiceGuide();
String userInput = SCANNER.next();
SCANNER.nextLine();
try {
validateUserMenuChoice(String.valueOf(userInput));
} catch (IllegalArgumentException illegalArgumentException) {
System.out.println(illegalArgumentException.getMessage());
return UserMenu.TERMINATE.getValue();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UserMenu는 사용자가 입력값으로 기대할 수 있는 선택지 중 하나라고 생각해요.
즉, 기능 선택이라는 역할을 하고 있는거죠.
그런데 예외에 대한 처리로 인위적으로 TERMINATE를 던지면 예외처리와 기능 선택이라는 작업이 섞이게 되요.
예외처리는 예외처리를 위한 다른 로직이 필요하다고 생각해요.

}
return userInput;
}

public String inputExpression() {
printCalculationGuide();
String expression = SCANNER.nextLine();
return expression;
}

private void printCalculationGuide() {
System.out.println("1 + 2 * 3와 같은 형식으로 계산하고자 하는 식을 입력하세요.");
System.out.print("> ");
}

private void printMenuChoiceGuide() {
System.out.println("\n[다음 중 원하시는 항목을 숫자로 입력하세요]");
System.out.println("1. 조회");
System.out.println("2. 계산");
System.out.println("3. 종료");
System.out.print("> 선택 : ");
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inputView에서 Output을 진행하고 있네요!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outputView클래스로 이동하여 수정하겠습니다


private void validateUserMenuChoice(String userInput) throws IllegalArgumentException {
if (!USER_MENU.contains(userInput)) {
throw new IllegalArgumentException(ExceptionMessage.INVALID_INPUT);
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contains 메소드를 사용하는 것도 좋지만, enum을 좀 더 잘 활용하려면 Menu를 검증하는 메소드를 직접 만드는 것도 좋아보여요.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum클래스 내에 메소드를 만들어서 사용하라는 말씀이실까요? enum을 더 잘 활용하려면 이라는 말이 무슨 뜻인지 잘 모르겠어요..

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵! 아래의 코멘트 참고하시면 될 것 같습니다

}
8 changes: 8 additions & 0 deletions src/main/java/co/programmers/view/CalculatorOutputView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package co.programmers.view;

public class CalculatorOutputView implements OutputView {

public void print(String content) {
System.out.println(">> 결과 : " + content);
}
}
8 changes: 8 additions & 0 deletions src/main/java/co/programmers/view/InputView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package co.programmers.view;

public interface InputView {

String inputUserMenu();

String inputExpression();
}
7 changes: 7 additions & 0 deletions src/main/java/co/programmers/view/OutputView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package co.programmers.view;

public interface OutputView {

void print(String content);

}