diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..097f9f98d --- /dev/null +++ b/.gitattributes @@ -0,0 +1,9 @@ +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# Linux start script should use lf +/gradlew text eol=lf + +# These are Windows script files and should use crlf +*.bat text eol=crlf + diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..301fec184 --- /dev/null +++ b/.gitignore @@ -0,0 +1,202 @@ +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 +.idea + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Intellij Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +# Azure Toolkit for IntelliJ plugin +# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij +.idea/**/azureSettings.xml + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +replay_pid* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### Gradle ### +.gradle +**/build/ +!src/**/build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Avoid ignore Gradle wrappper properties +!gradle-wrapper.properties + +# Cache of project +.gradletasknamecache + +# Eclipse Gradle plugin generated files +# Eclipse Core +.project +# JDT-specific (Eclipse Java Development Tools) +.classpath + +### Gradle Patch ### +# Java heap dump +*.hprof + +# Ignore Gradle build output directory +build diff --git a/README.md b/README.md index c1c982e55..8743e2d87 100644 --- a/README.md +++ b/README.md @@ -1,69 +1,176 @@ # java_calculator -자바 계산기 구현 미션 Repository입니다. - -### 이곳은 공개 Repo입니다. -1. 여러분의 포트폴리오로 사용하셔도 됩니다. -2. 때문에 이 repo를 fork한 뒤 -3. 여러분의 개인 Repo에 작업하며 -4. 이 Repo에 PR을 보내어 멘토의 코드 리뷰와 피드백을 받으세요. - -### Branch 명명 규칙 + 팀의 PR규칙 정하기 -1. 여러분 repo는 알아서 해주시고 😀(본인 레포니 main으로 하셔두 되져) -2. prgrms-be-devcourse/spring-board 레포로 PR시 branch는 gituser_id을 적어주세요 :) - - base repo : `여기repo` base : `username` ← head repo : `여러분repo` compare : `main`또는 `github_id` -3. 실제 진행할 PR규칙은 멘토+팀원들과 정하여 진행해주세요 :) - - ← head repo : `여러분repo` compare : `main`로 할지 - - 또는 ← head repo : `여러분repo` compare : `github_id`로 할지 -- 참고 : [Github 위치 및 피드백 기준 가이드](https://www.notion.so/backend-devcourse/Github-e1a0908a6bbf4aeaa5a62981499bb215) - -### 과제를 통해 기대하는 역량 - -- 깃허브를 통한 코드리뷰를 경험해보자 -- 기본적인 테스트 코드 작성 및 활용하는 능력해보자 -- 스스로 OOP를 생각하고 코드로 옮길 수 있는 능력해보자 - -### 요구사항 -- 콘솔로 구현입니다.(스윙으로 구현하시는 분들 계실까봐) -- 객체지향적인 코드로 계산기 구현하기 - - [ ] 더하기 - - [ ] 빼기 - - [ ] 곱하기 - - [ ] 나누기 - - [ ] 우선순위(사칙연산) -- [ ] 테스트 코드 구현하기 -- [ ] 계산 이력을 맵으로 데이터 저장기능 만들기 - - 애플리케이션이 동작하는 동안 데이터베이스 외에 데이터를 저장할 수 있는 방법을 고안해보세요. -- (선택) 정규식 사용 - -### 실행결과(콘솔) +> 순수 자바로 OOP를 적용하여 계산기 만들기 - 김영주 + +## 요구사항 + +- [x] 사용자 입력으로 메뉴를 선택 +- [x] 식을 입력받아 후위 연산식으로 변경 +- [x] 덧셈 +- [x] 뺄셈 +- [x] 곱셈 +- [x] 나눗셈 +- [x] 단일 내역을 저장하는 기능 +- [x] 전체 내역을 조회하는 기능 + + + + +## 실행결과(콘솔) ``` -1. 조회 -2. 계산 +1.조회 +2.계산 +3.종료 + +메뉴를 입력해주세요(숫자만 입력) : 2 + +계산식을 입력하세요(자연수, 사칙연산, 공백 기준) : 3 + 5 * 2 +계산 결과 : 13 + +1.조회 +2.계산 +3.종료 + +메뉴를 입력해주세요(숫자만 입력) : 2 -선택 : 2 +계산식을 입력하세요(자연수, 사칙연산, 공백 기준) : 4 - 2 / 2 + 4 * 2 +계산 결과 : 11 -1 + 2 -3 +1.조회 +2.계산 +3.종료 -1. 조회 -2. 계산 +메뉴를 입력해주세요(숫자만 입력) : 1 +3 + 5 * 2 = 13 +4 - 2 / 2 + 4 * 2 = 11 -선택 : 2 +1.조회 +2.계산 +3.종료 + +메뉴를 입력해주세요(숫자만 입력) : 3 + +프로그램을 종료합니다. +``` + + + +## 주요 객체 목록 + +1. `클라이언트(view/)` + - 입력(InputView.java) + - 메뉴 입력 + - 계산식 입력 + - 출력(OutputView.java) + - 응답받은 결과(내역 혹은 계산 값) 출력 +2. `컨트롤러(controller/)` + - 메뉴(MainController.java) + - 메뉴 선택(조회 서비스, 계산 서비스) +3. `서비스(service/)` + - 계산(Calculator.java) + - 단일 계산 내역을 저장 + - 계산식 결과를 반환 +4. `저장소(storage/)` + - 계산 내역 저장소(HistoryStorage.java) + - Map을 이용해 저장 + - 정상과 예외 내역 모두 저장 + - 조회 시, 전체 계산 내역 반환 +5. `엔티티(entity/)` + - 메뉴(Menu.java) + - 조회, 계산, 종료 + - 선택한 메뉴 번호에 따라 메뉴를 반환 + - 연산자(Operator.java) + - 사칙연산(+, -, *, /) + - 연산자 우선순위에 따라 연산 + - 나눗셈을 할 때 제수가 0이면 안됨 + - 식(Expression.java) + - 피연산자 2개 + - 연산자 1개 + - 작은 식(ex. 3 + 5) 단위의 결과값 반환 + - 표기법(Notation.java) + - 중위표현식(InfixNotation.java) + - 후위표현식(PostfixNotation.java) +6. `예외처리(exception/)` + - 메뉴 예외 + - 존재하지 않는 메뉴 선택 + - 아무것도 입력하지 않음 (입력값을 trim 처리했을 때 공백인 경우) + - 수식 예외 + - 연산자 개수 부족 + - 피연산자 개수 부족 + - 연산자 값이 올바르지 않음 (사칙연산 이외의 기호가 입력된 경우) + - 피연산자 값이 올바르지 않음 (숫자가 아닌 경우, 피연산자와 연산자가 붙어있는 경우) + - 너무 큰 숫자일 경우 (추후 추가 사항) + - 괄호 짝이 맞지 않음(추후 추가 사항) + - 계산 예외 + - 나눗셈의 제수가 0인 경우 + + + +## 프로그램 구조도 + +![image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fb33dec55-c288-45fc-9c6c-20bd669ca9c6%2FUntitled.png?table=block&id=143ebc12-a4d1-49aa-ad0c-0599926d6299&spaceId=a592f9c1-ca11-4018-a4f6-7dbbcd6b008e&width=2000&userId=55d7c337-b594-4735-9e25-4588aa133d55&cache=v2) + +![image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F81cb2325-93dc-430b-bc82-31b85f7c52e0%2FUntitled.png?table=block&id=4caeb1b6-1ed3-402e-955c-0f002c7277fc&spaceId=a592f9c1-ca11-4018-a4f6-7dbbcd6b008e&width=2000&userId=55d7c337-b594-4735-9e25-4588aa133d55&cache=v2) + + + +## 패키지 구조 + +``` +src/main/java/calculator/ +- view/ + - InputView.java + - OutputView.java + +- controller/ + - MainController.java + +- service/ + - Calculator.java + +- storage/ + - HistoryStorage.java + +- entity/ + - Menu.java + - Operator.java + - Expression.java + - Notation.java + - InfixNotation.java + - PostfixNotation.java + +- exception/ + - MenuInputException.java + - ExpressionInputException.java + +- utils/ + - StringUtils.java +``` -1 + 2 * 3 -7 -1. 조회 -2. 계산 -선택 : 1 +## Git commit convention -1 + 2 = 3 -1 + 2 * 3 = 7 +> [Angular JS commit convention](https://velog.io/@outstandingboy/Git-커밋-메시지-규약-정리-the-AngularJS-commit-conventions)를 참고 -선택 : 2 +```markdown +[커밋 메시지 헤더] +(): + │ │ │ + │ │ └─⫸ 현재 시제로 작성한다. 마침표로 끝내지 않는다. + │ │ + │ └─⫸ Commit Scope: 어느 부분을 수정했는지 작성한다.(생략 가능) + │ + └─⫸ Commit Type: build|docs|feat|fix|refactor|test|style -3 - 2 * 2 --1 +[커밋 메시지 바디] +- 현재 시제로 작성한다. +- 변경 전과 후의 차이점과 이유에 대해 작성한다. ``` +- `feat` : 새로운 기능 추가 +- `fix` : 버그 수정 +- `docs` : 문서 관련 +- `style` : 스타일 변경 (포매팅 수정, 들여쓰기 추가, …) +- `refactor` : 코드 리팩토링 +- `test` : 테스트 관련 코드 +- `build` : 빌드 관련 파일 수정 diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 000000000..2dc328e01 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,42 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * This generated file contains a sample Java application project to get you started. + * For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle + * User Manual available at https://docs.gradle.org/8.1.1/userguide/building_java_projects.html + */ + +plugins { + // Apply the application plugin to add support for building a CLI application in Java. + id 'application' +} + +repositories { + // Use Maven Central for resolving dependencies. + mavenCentral() +} + +dependencies { + // Use JUnit Jupiter for testing. + testImplementation 'org.junit.jupiter:junit-jupiter:5.9.1' + + // This dependency is used by the application. + implementation 'com.google.guava:guava:31.1-jre' +} + +// Apply a specific Java toolchain to ease working on different environments. +java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } +} + +application { + // Define the main class for the application. + mainClass = 'calculator.App' +} + +tasks.named('test') { + // Use JUnit Platform for unit tests. + useJUnitPlatform() +} diff --git a/app/src/main/java/calculator/App.java b/app/src/main/java/calculator/App.java new file mode 100644 index 000000000..3f43c7edc --- /dev/null +++ b/app/src/main/java/calculator/App.java @@ -0,0 +1,28 @@ +package calculator; + +import static calculator.view.OutputView.printWithLineBreak; +import static calculator.view.OutputView.showQuitMessage; + +import calculator.controller.MainController; +import calculator.entity.Notation; +import calculator.entity.PostfixNotation; +import calculator.service.Calculator; +import calculator.storage.HistoryStorage; + +public class App { + + public static void main(String[] args) { + HistoryStorage historyStorage = new HistoryStorage(); + Notation notation = new PostfixNotation(); + Calculator calculator = new Calculator(historyStorage, notation); + MainController mainController = new MainController(historyStorage, calculator); + + try { + mainController.run(); + } catch (Exception e) { + printWithLineBreak(e.getMessage()); + } finally { + showQuitMessage(); + } + } +} diff --git a/app/src/main/java/calculator/controller/MainController.java b/app/src/main/java/calculator/controller/MainController.java new file mode 100644 index 000000000..1d08fc2b7 --- /dev/null +++ b/app/src/main/java/calculator/controller/MainController.java @@ -0,0 +1,56 @@ +package calculator.controller; + +import static calculator.entity.Menu.getSelectedMenu; +import static calculator.view.InputView.inputExpression; +import static calculator.view.InputView.inputMenuNumber; +import static calculator.view.OutputView.showAllHistory; +import static calculator.view.OutputView.showCalculationResult; +import static calculator.view.OutputView.showExpressionInputMessage; +import static calculator.view.OutputView.showMenu; + +import calculator.entity.Menu; +import calculator.service.Calculator; +import calculator.storage.HistoryStorage; + +public class MainController { + + private final HistoryStorage historyStorage; + private final Calculator calculator; + + public MainController(HistoryStorage historyStorage, Calculator calculator) { + this.historyStorage = historyStorage; + this.calculator = calculator; + } + + public void run() { + boolean isRunning = true; + + while (isRunning) { + showMenu(); + + int menuNumber = inputMenuNumber(); + Menu selectedMenu = getSelectedMenu(menuNumber); + + isRunning = !selectedMenu.isQuit(); + + execute(selectedMenu); + } + } + + private void execute(Menu selectedMenu) { + if (selectedMenu.isReadHistory()) { + String[] allHistory = historyStorage.readAllHistory(); + showAllHistory(allHistory); + + return; + } + + if (selectedMenu.isCalculate()) { + showExpressionInputMessage(); + String expression = inputExpression(); + + int result = calculator.calculate(expression); + showCalculationResult(result); + } + } +} diff --git a/app/src/main/java/calculator/entity/Expression.java b/app/src/main/java/calculator/entity/Expression.java new file mode 100644 index 000000000..0cbb6854c --- /dev/null +++ b/app/src/main/java/calculator/entity/Expression.java @@ -0,0 +1,18 @@ +package calculator.entity; + +public class Expression { + + private final Operator operator; + private final int operand1; + private final int operand2; + + public Expression(Operator operator, int operand1, int operand2) { + this.operator = operator; + this.operand1 = operand1; + this.operand2 = operand2; + } + + public int evaluate() { + return operator.evaluate(operand1, operand2); + } +} diff --git a/app/src/main/java/calculator/entity/InfixNotation.java b/app/src/main/java/calculator/entity/InfixNotation.java new file mode 100644 index 000000000..56ecb2408 --- /dev/null +++ b/app/src/main/java/calculator/entity/InfixNotation.java @@ -0,0 +1,40 @@ +package calculator.entity; + +import static calculator.entity.Operator.getOperatorWithSameSymbol; +import static calculator.utils.StringUtils.isNumeric; +import static calculator.utils.StringUtils.splitToElements; + +import java.util.Optional; +import java.util.Stack; + +public class InfixNotation implements Notation { + + @Override + public String[] makeElements(String expression) { + return splitToElements(expression); + } + + @Override + public Optional makeExpression(Stack operands, Stack operators, + String element) { + if (!isNumeric(element)) { + Operator operator = getOperatorWithSameSymbol(element); + operators.push(operator); + + return Optional.empty(); + } + + if (operators.isEmpty()) { + int operand = Integer.parseInt(element); + operands.push(operand); + + return Optional.empty(); + } + + Operator operator = operators.pop(); + int operand1 = operands.pop(); + int operand2 = Integer.parseInt(element); + + return Optional.of(new Expression(operator, operand1, operand2)); + } +} diff --git a/app/src/main/java/calculator/entity/Menu.java b/app/src/main/java/calculator/entity/Menu.java new file mode 100644 index 000000000..e2d8e8090 --- /dev/null +++ b/app/src/main/java/calculator/entity/Menu.java @@ -0,0 +1,48 @@ +package calculator.entity; + +import calculator.exception.MenuInputException; +import java.util.Arrays; + +public enum Menu { + + READ_HISTORY(1, "조회"), + CALCULATE(2, "계산"), + QUIT(3, "종료"); + + private static final String NOT_EXIST_MENU_MESSAGE = "존재하지 않는 메뉴입니다."; + private final int number; + private final String name; + + Menu(int number, String name) { + this.number = number; + this.name = name; + } + + public static Menu getSelectedMenu(int selectedMenuNumber) { + return Arrays.stream(Menu.values()) + .filter(menu -> selectedMenuNumber == menu.getNumber()) + .findFirst() + .orElseThrow(() -> new MenuInputException(NOT_EXIST_MENU_MESSAGE)); + } + + public boolean isReadHistory() { + return this == Menu.READ_HISTORY; + } + + public boolean isCalculate() { + return this == Menu.CALCULATE; + } + + public boolean isQuit() { + return this == Menu.QUIT; + } + + public int getNumber() { + return number; + } + + @Override + public String toString() { + return number + "." + name; + } +} diff --git a/app/src/main/java/calculator/entity/Notation.java b/app/src/main/java/calculator/entity/Notation.java new file mode 100644 index 000000000..db3cf22ae --- /dev/null +++ b/app/src/main/java/calculator/entity/Notation.java @@ -0,0 +1,12 @@ +package calculator.entity; + +import java.util.Optional; +import java.util.Stack; + +public interface Notation { + + String[] makeElements(String expression); + + Optional makeExpression(Stack operands, Stack operators, + String element); +} diff --git a/app/src/main/java/calculator/entity/Operator.java b/app/src/main/java/calculator/entity/Operator.java new file mode 100644 index 000000000..da77cf4f6 --- /dev/null +++ b/app/src/main/java/calculator/entity/Operator.java @@ -0,0 +1,72 @@ +package calculator.entity; + +import calculator.exception.ExpressionInputException; +import java.util.Arrays; + +public enum Operator { + ADD("+", 1) { + @Override + public int evaluate(int operand1, int operand2) { + return operand1 + operand2; + } + }, + SUBTRACT("-", 1) { + @Override + public int evaluate(int operand1, int operand2) { + return operand1 - operand2; + } + }, + MULTIPLY("*", 2) { + @Override + public int evaluate(int operand1, int operand2) { + return operand1 * operand2; + } + }, + DIVIDE("/", 2) { + private static final int ZERO = 0; + private static final String DIVISION_BY_ZERO_MESSAGE = "0으로 나눌 수 없습니다."; + + @Override + public int evaluate(int operand1, int operand2) { + validateIsDivisorNotZero(operand2); + return operand1 / operand2; + } + + private void validateIsDivisorNotZero(int divisor) { + if (divisor == ZERO) { + throw new ArithmeticException(DIVISION_BY_ZERO_MESSAGE); + } + } + }; + + private static final String NOT_MATCHING_ANY_SYMBOL_MESSAGE = "일치하는 연산자가 없습니다."; + + private final String symbol; + private final int priority; + + Operator(String symbol, int priority) { + this.symbol = symbol; + this.priority = priority; + } + + public static Operator getOperatorWithSameSymbol(String elementSymbol) { + return Arrays.stream(Operator.values()) + .filter(operator -> elementSymbol.equals(operator.getSymbol())) + .findFirst() + .orElseThrow(() -> new ExpressionInputException(NOT_MATCHING_ANY_SYMBOL_MESSAGE)); + } + + public boolean isLowerOrSamePriorityThan(Operator otherOperator) { + return priority <= otherOperator.getPriority(); + } + + public String getSymbol() { + return symbol; + } + + public int getPriority() { + return priority; + } + + public abstract int evaluate(int operand1, int operand2); +} diff --git a/app/src/main/java/calculator/entity/PostfixNotation.java b/app/src/main/java/calculator/entity/PostfixNotation.java new file mode 100644 index 000000000..789c399da --- /dev/null +++ b/app/src/main/java/calculator/entity/PostfixNotation.java @@ -0,0 +1,92 @@ +package calculator.entity; + +import static calculator.entity.Operator.getOperatorWithSameSymbol; +import static calculator.utils.StringUtils.isNumeric; +import static calculator.utils.StringUtils.splitToElements; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.Stack; + +public class PostfixNotation implements Notation { + + @Override + public String[] makeElements(String expression) { + String[] infixElements = splitToElements(expression); + + return convertToPostfix(infixElements); + } + + @Override + public Optional makeExpression(Stack operands, Stack operators, + String element) { + if (isNumeric(element)) { + int operand = Integer.parseInt(element); + operands.push(operand); + + return Optional.empty(); + } + + Operator operator = getOperatorWithSameSymbol(element); + int operand2 = operands.pop(); + int operand1 = operands.pop(); + + return Optional.of(new Expression(operator, operand1, operand2)); + } + + private String[] convertToPostfix(String[] elements) { + List postfixElements = new ArrayList<>(); + Stack operators = new Stack<>(); + + for (String element : elements) { + saveElement(postfixElements, operators, element); + } + + while (!operators.isEmpty()) { + addTopOfOperatorStackToPostfixElements(postfixElements, operators); + } + + return postfixElements.toArray(new String[0]); + } + + private void saveElement(List postfixElements, Stack operators, + String element) { + if (isNumeric(element)) { + postfixElements.add(element); + + return; + } + + pushOperator(postfixElements, operators, element); + } + + private void pushOperator(List postfixElements, Stack operators, + String element) { + Operator operator = getOperatorWithSameSymbol(element); + + while (isLowerOrSamePriorityThanTop(operators, operator)) { + addTopOfOperatorStackToPostfixElements(postfixElements, operators); + } + + operators.push(operator); + } + + private boolean isLowerOrSamePriorityThanTop(Stack operators, Operator operator) { + if (operators.isEmpty()) { + return false; + } + + Operator topOfStack = operators.peek(); + + return operator.isLowerOrSamePriorityThan(topOfStack); + } + + private void addTopOfOperatorStackToPostfixElements(List postfixElements, + Stack operators) { + Operator topOfStack = operators.pop(); + String symbol = topOfStack.getSymbol(); + + postfixElements.add(symbol); + } +} diff --git a/app/src/main/java/calculator/exception/ExpressionInputException.java b/app/src/main/java/calculator/exception/ExpressionInputException.java new file mode 100644 index 000000000..7a7c30aa5 --- /dev/null +++ b/app/src/main/java/calculator/exception/ExpressionInputException.java @@ -0,0 +1,8 @@ +package calculator.exception; + +public class ExpressionInputException extends RuntimeException { + + public ExpressionInputException(String message) { + super(message); + } +} diff --git a/app/src/main/java/calculator/exception/MenuInputException.java b/app/src/main/java/calculator/exception/MenuInputException.java new file mode 100644 index 000000000..cc9905008 --- /dev/null +++ b/app/src/main/java/calculator/exception/MenuInputException.java @@ -0,0 +1,8 @@ +package calculator.exception; + +public class MenuInputException extends RuntimeException { + + public MenuInputException(String message) { + super(message); + } +} diff --git a/app/src/main/java/calculator/service/Calculator.java b/app/src/main/java/calculator/service/Calculator.java new file mode 100644 index 000000000..7e0d679bb --- /dev/null +++ b/app/src/main/java/calculator/service/Calculator.java @@ -0,0 +1,43 @@ +package calculator.service; + +import static calculator.utils.StringUtils.makeHistory; + +import calculator.entity.Expression; +import calculator.entity.Notation; +import calculator.entity.Operator; +import calculator.storage.HistoryStorage; +import java.util.Stack; + +public class Calculator { + + private final HistoryStorage historyStorage; + private final Notation notation; + + public Calculator(HistoryStorage historyStorage, Notation notation) { + this.historyStorage = historyStorage; + this.notation = notation; + } + + public int calculate(String expression) { + String[] elements = notation.makeElements(expression); + int result = evaluate(elements); + + String history = makeHistory(expression, result); + historyStorage.save(history); + + return result; + } + + private int evaluate(String[] elements) { + Stack operands = new Stack<>(); + Stack operators = new Stack<>(); + + for (String element : elements) { + notation.makeExpression(operands, operators, element) + .map(Expression::evaluate) + .ifPresent(operands::push); + } + + return operands.pop(); + } +} diff --git a/app/src/main/java/calculator/storage/HistoryStorage.java b/app/src/main/java/calculator/storage/HistoryStorage.java new file mode 100644 index 000000000..78e808eaf --- /dev/null +++ b/app/src/main/java/calculator/storage/HistoryStorage.java @@ -0,0 +1,17 @@ +package calculator.storage; + +import java.util.ArrayList; +import java.util.List; + +public class HistoryStorage { + + private final List storage = new ArrayList<>(); + + public void save(String history) { + storage.add(history); + } + + public String[] readAllHistory() { + return storage.toArray(String[]::new); + } +} diff --git a/app/src/main/java/calculator/utils/StringUtils.java b/app/src/main/java/calculator/utils/StringUtils.java new file mode 100644 index 000000000..4ef2ddf6c --- /dev/null +++ b/app/src/main/java/calculator/utils/StringUtils.java @@ -0,0 +1,25 @@ +package calculator.utils; + +public class StringUtils { + + private static final String NUMERIC_REGEX = "\\d+"; + private static final String EXPRESSION_REGEX = "^\\d+(\\s[+\\-*/]\\s\\d+)*"; + private static final String EMPTY = " "; + private static final String EQUAL = " = "; + + public static boolean isNumeric(String numericString) { + return numericString.matches(NUMERIC_REGEX); + } + + public static boolean isMatchingExpressionRegex(String expression) { + return expression.matches(EXPRESSION_REGEX); + } + + public static String[] splitToElements(String expression) { + return expression.split(EMPTY); + } + + public static String makeHistory(String expression, int calculationResult) { + return expression + EQUAL + calculationResult; + } +} diff --git a/app/src/main/java/calculator/view/InputView.java b/app/src/main/java/calculator/view/InputView.java new file mode 100644 index 000000000..5f8c81803 --- /dev/null +++ b/app/src/main/java/calculator/view/InputView.java @@ -0,0 +1,52 @@ +package calculator.view; + +import static calculator.utils.StringUtils.isMatchingExpressionRegex; +import static calculator.utils.StringUtils.isNumeric; + +import calculator.exception.ExpressionInputException; +import calculator.exception.MenuInputException; +import java.util.Scanner; + +public final class InputView { + + private static final Scanner SCANNER = new Scanner(System.in); + private static final String NOT_NUMERIC_MENU_INPUT_MESSAGE = "메뉴는 숫자만 입력 가능합니다."; + private static final String INVALID_EXPRESSION_MESSAGE = "올바르지 않은 계산식이 입력되었습니다."; + + private InputView() { + } + + public static int inputMenuNumber() { + String menuInput = readLineWithTrimming(); + validateMenuInput(menuInput); + + return Integer.parseInt(menuInput); + } + + public static String inputExpression() { + String expression = readLineWithTrimming(); + validateExpression(expression); + + return expression; + } + + private static String readLineWithTrimming() { + return readLine().trim(); + } + + private static String readLine() { + return SCANNER.nextLine(); + } + + private static void validateMenuInput(String menu) { + if (!isNumeric(menu)) { + throw new MenuInputException(NOT_NUMERIC_MENU_INPUT_MESSAGE); + } + } + + private static void validateExpression(String expression) { + if (!isMatchingExpressionRegex(expression)) { + throw new ExpressionInputException(INVALID_EXPRESSION_MESSAGE); + } + } +} diff --git a/app/src/main/java/calculator/view/OutputView.java b/app/src/main/java/calculator/view/OutputView.java new file mode 100644 index 000000000..b4abea1ea --- /dev/null +++ b/app/src/main/java/calculator/view/OutputView.java @@ -0,0 +1,67 @@ +package calculator.view; + +import calculator.entity.Menu; + +public final class OutputView { + + private static final String MENU_INPUT_MESSAGE = "메뉴를 입력해주세요(숫자만 입력) : "; + private static final String EXPRESSION_INPUT_MESSAGE = "계산식을 입력하세요(자연수, 사칙연산, 공백 기준) : "; + private static final String QUIT_MESSAGE = "프로그램을 종료합니다."; + private static final String CALCULATION_RESULT_MESSAGE = "계산 결과 : "; + private static final String EMPTY_HISTORY_MESSAGE = "계산 내역이 존재하지 않습니다."; + private static final int EMPTY_LENGTH = 0; + + private OutputView() { + } + + public static void showMenu() { + printMultiple(Menu.values()); + printWithLineBreak(); + printWithoutLineBreak(MENU_INPUT_MESSAGE); + } + + public static void showExpressionInputMessage() { + printWithLineBreak(); + printWithoutLineBreak(EXPRESSION_INPUT_MESSAGE); + } + + public static void showQuitMessage() { + printWithLineBreak(); + printWithLineBreak(QUIT_MESSAGE); + } + + public static void showCalculationResult(int calculationResult) { + printWithLineBreak(CALCULATION_RESULT_MESSAGE + calculationResult); + printWithLineBreak(); + } + + public static void showAllHistory(String[] allHistory) { + if (allHistory.length == EMPTY_LENGTH) { + printWithLineBreak(EMPTY_HISTORY_MESSAGE); + printWithLineBreak(); + + return; + } + + printMultiple(allHistory); + printWithLineBreak(); + } + + public static void printWithLineBreak() { + System.out.println(); + } + + public static void printWithLineBreak(String output) { + System.out.println(output); + } + + public static void printWithoutLineBreak(String output) { + System.out.print(output); + } + + public static void printMultiple(T[] outputs) { + for (T output : outputs) { + System.out.println(output); + } + } +} diff --git a/app/src/test/java/calculator/service/InfixCalculatorTest.java b/app/src/test/java/calculator/service/InfixCalculatorTest.java new file mode 100644 index 000000000..037bc7a00 --- /dev/null +++ b/app/src/test/java/calculator/service/InfixCalculatorTest.java @@ -0,0 +1,43 @@ +package calculator.service; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import calculator.entity.InfixNotation; +import calculator.entity.Notation; +import calculator.storage.HistoryStorage; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +public class InfixCalculatorTest { + + private Calculator calculator; + private HistoryStorage historyStorage; + private Notation notation; + + @BeforeEach + void init() { + historyStorage = new HistoryStorage(); + notation = new InfixNotation(); + calculator = new Calculator(historyStorage, notation); + } + + @DisplayName("중위표현식으로 계산할 때 정상적으로 결과 값이 나오는지 테스트") + @ParameterizedTest(name = "{0} = {1}") + @CsvSource({ + "3 + 5, 8", + "4 - 2, 2", + "3 * 6, 18", + "20 / 5, 4", + "3 + 4 * 5 - 2 / 6 + 8, 13", + "10 + 2 * 7 - 3 / 5 - 1, 15", + "1 - 2 / 3 + 4 * 5, 20", + "5 * 4 / 2 + 3 - 1, 12" + }) + void integrationTestWithInfixNotation(String expression, int answer) { + int result = calculator.calculate(expression); + + assertEquals(result, answer); + } +} diff --git a/app/src/test/java/calculator/service/PostfixCalculatorTest.java b/app/src/test/java/calculator/service/PostfixCalculatorTest.java new file mode 100644 index 000000000..b77c5fe88 --- /dev/null +++ b/app/src/test/java/calculator/service/PostfixCalculatorTest.java @@ -0,0 +1,43 @@ +package calculator.service; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import calculator.entity.Notation; +import calculator.entity.PostfixNotation; +import calculator.storage.HistoryStorage; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +public class PostfixCalculatorTest { + + private Calculator calculator; + private HistoryStorage historyStorage; + private Notation notation; + + @BeforeEach + void init() { + historyStorage = new HistoryStorage(); + notation = new PostfixNotation(); + calculator = new Calculator(historyStorage, notation); + } + + @DisplayName("후위표현식으로 계산할 때 정상적으로 결과 값이 나오는지 테스트") + @ParameterizedTest(name = "{0} = {1}") + @CsvSource({ + "3 + 5, 8", + "4 - 2, 2", + "3 * 6, 18", + "20 / 5, 4", + "3 + 4 * 5 - 2 / 6 + 8, 31", + "10 + 2 * 7 - 3 / 5 - 1, 23", + "1 - 2 / 3 + 4 * 5, 21", + "5 * 4 / 2 + 3 - 1, 12" + }) + void integrationTestWithPostfixNotation(String expression, int answer) { + int result = calculator.calculate(expression); + + assertEquals(result, answer); + } +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..c1962a79e Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..37aef8d3f --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +networkTimeout=10000 +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 000000000..aeb74cbb4 --- /dev/null +++ b/gradlew @@ -0,0 +1,245 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 000000000..93e3f59f1 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 000000000..24a4aa2a0 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,16 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * The settings file is used to specify which projects to include in your build. + * + * Detailed information about configuring a multi-project build in Gradle can be found + * in the user manual at https://docs.gradle.org/8.1.1/userguide/multi_project_builds.html + */ + +plugins { + // Apply the foojay-resolver plugin to allow automatic download of JDKs + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0' +} + +rootProject.name = 'java-calculator' +include('app')