Coder Social home page Coder Social logo

java-string-adder's Introduction

🚀 문자열 덧셈 계산기

📒 기능 요구 사항

  • 쉼표(,) 또는 콜론(:)을 구분자로 가지는 문자열을 전달하는 경우 구분자를 기준으로 분리한 각 숫자의 합을 반환 (예: “” => 0, "1,2" => 3, "1,2,3" => 6, “1,2:3” => 6)
  • 앞의 기본 구분자(쉼표, 콜론)외에 커스텀 구분자를 지정할 수 있다. 커스텀 구분자는 문자열 앞부분의 “//”와 “\n” 사이에 위치하는 문자를 커스텀 구분자로 사용한다. 예를 들어 “//;\n1;2;3”과 같이 값을 입력할 경우 커스텀 구분자는 세미콜론(;)이며, 결과 값은 6이 반환되어야 한다.
  • 문자열 계산기에 숫자 이외의 값 또는 음수를 전달하는 경우 RuntimeException 예외를 throw한다.

🛠️ 구현할 기능 목록

입력 처리

  • 계산할 문자열을 입력 받을 수 있다.
  • 허용하는 구분자를 기반으로 입력 문자열에서 피연산자를 파싱할 수 있다.

입력 검증

  • 음수가 피연산자로 들어오는 경우 RuntimeException 예외를 throw 한다.
  • 숫자 이외의 값이 피연산자로 지정되는 경우 RuntimeException 예외를 throw 한다.
  • 인식할 수 없는 구분자가 식별되면 RuntimeException 예외를 throw 한다.

핵심 도메인 기능

  • 피연산자들을 더할 수 있다.
  • 더한 결과 값을 포장하여 뷰에 전달할 수 있다.

출력 처리

  • 결과 값을 출력할 수 있다.

🤔 피드백 받기!

  • 책임별로 클래스를 분리하다보니 입력 받는 부분에서 특정 로직에 굉장히 종속적인 의존관계가 늘어남
    • 재사용성을 높이기 위해 파라미터로 로직을 캐싱하면 될까..?
  • 정규식 패턴이 예시대로 먹지 않는다..!
    • 입력은 이스케이프가 된채로 인식하는 것 같고 테스트에서는 줄바꿈으로 인식하는 것 같은데...
    • 둘 사이를 이스케이프 처리하고 어떻게 해도 콘솔에서는 오류가 나고 테스트는 통과해버림.. 피드백 잘 듣자

java-string-adder's People

Contributors

libienz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.