Skip to content

[문자열 계산기] 이성준 미션 제출합니다.#10

Open
szoon2426 wants to merge 4 commits into
Java-JavaScript-Language-Stuty:mainfrom
szoon2426:develope
Open

[문자열 계산기] 이성준 미션 제출합니다.#10
szoon2426 wants to merge 4 commits into
Java-JavaScript-Language-Stuty:mainfrom
szoon2426:develope

Conversation

@szoon2426

Copy link
Copy Markdown

No description provided.

@szoon2426 szoon2426 changed the title [문자열 계산기] 이성준 제출합니다. [문자열 계산기] 이성준 미션 제출합니다. Feb 7, 2025

@moongua404 moongua404 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

첫 주차라 자바가 익숙하지 않으셨을텐데 수고 많으셨습니다!

// TODO: 프로그램 구현

// 변수 선언
String stnc; // 입력값

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

변수명을 축약하지 않는게 더 좋을 것 같아요!

if(stnc.substring(0,2).equals("//") && stnc.substring(3,5).equals("\\n")){
customId = stnc.charAt(2);
hasCustomed = true;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

정규 표현식 쓰면 더 쉽게 확인 및 추출할 수 있을 것 같아요!

for(; i<stnc.length(); i++){
if(condition){ // , 이나 : 나오면 그 전까지를 answer에 더함
for(int j = i-1; j>=odr; j--){
answer += (stnc.charAt(j)-48) * tmp;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

문자를 숫자로 변환해주는 API를 활용하면 더 안정적이고 가독성이 높을 것 같아요

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

그것 외에도 반복문으로 감싸진 answer+=~~ 근방 부분이 반복되니 함수로 분리해도 좋을 것 같습니다~~

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

동의합니다.
Math.pow 를 써도 괜찮을 것 같습니다.

for(int j = i-1; j>=odr; j--){
answer += (stnc.charAt(j)-48) * tmp;
tmp *= 10;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

이 부분도 substring으로 추출한 다음 바로 변환하는게 더 읽기 쉽지 않을까요?

}

int i = 0; boolean condition= stnc.charAt(i) == ',' || stnc.charAt(i) == ':'; // 오류가 나는데 왜 나는지 모르겠어요,,,,
if(hasCustomed){i=5; condition = condition || stnc.charAt(i) == customId;}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

이 부분 로직이 조금 꼬인 것 같아요 condition을 루프 안에서 확인하는게 맞을 것 같아요!

@daeGULLL daeGULLL Feb 9, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

동의합니다~~또 보니 이 검사 후에 루프문을 돌며 입력값의 매 자리를 int 변환해 더하시는 것 같은데 그러시려면 저 , 나 : 을 제거하고 숫자별로 분리해 리스트에 담아두는 식으로 하셔야할 것 같아요~

for(int j = i; j>=odr; j--){
answer += (stnc.charAt(j)-48) * tmp;
tmp *= 10;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

요 부분을 함수로 추출하면 재사용성이 높아지지 않을까요?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

동의합니다.

@daeGULLL

daeGULLL commented Feb 9, 2025

Copy link
Copy Markdown

세부 설명이랑 커밋 컨벤션 따라해보기 정도가 피드백 내용일 것 같습니다! 수고하셨습니다~~

@KIM-GOING KIM-GOING left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

저도 마찬가지 이지만 내가 원하는 기능에 대한 API가 존재하는 지 알아보면 공부에 도움이 될 거 같아요! 수고하셨습니다:)

Comment on lines +28 to +32
if(stnc.substring(0,2).equals("//") && stnc.substring(3,5).equals("\\n")){
customId = stnc.charAt(2);
hasCustomed = true;
i=5;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

커스텀 구분자가 두 문자 이상일 수도 있다고 생각하고 코드를 짜 보는 것도 좋을 거 같아요!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants