Skip to content

Kimyoonbeom/CalculatorProject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

11 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

[Spring 6๊ธฐ] CH 2 ๊ณ„์‚ฐ๊ธฐ ๊ณผ์ œ

calculatorLevel1 ํด๋ž˜์Šค ์—†์ด ๊ธฐ๋ณธ์ ์ธ ์—ฐ์‚ฐ์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ๋Š” ๊ณ„์‚ฐ๊ธฐ ๋งŒ๋“ค๊ธฐ.

  1. ์–‘์˜ ์ •์ˆ˜(0 ํฌํ•จ)๋ฅผ ์ž…๋ ฅ๋ฐ›๊ธฐ

  2. ์‚ฌ์น™์—ฐ์‚ฐ ๊ธฐํ˜ธ(โž•,โž–,โœ–๏ธ,โž—)๋ฅผ ์ž…๋ ฅ๋ฐ›๊ธฐ

  3. ์œ„์—์„œ ์ž…๋ ฅ๋ฐ›์€ ์–‘์˜ ์ •์ˆ˜ 2๊ฐœ์™€ ์‚ฌ์น™์—ฐ์‚ฐ ๊ธฐํ˜ธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์—ฐ์‚ฐ์„ ์ง„ํ–‰ํ•œ ํ›„ ๊ฒฐ๊ณผ๊ฐ’์„ ์ถœ๋ ฅํ•˜๊ธฐ
    • ํ‚ค์›Œ๋“œ: if, swich
    • ์—ฐ์‚ฐ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•  ๊ฒฝ์šฐ ํ•ด๋‹น ์˜ค๋ฅ˜์— ๋Œ€ํ•œ ๋‚ด์šฉ์„ ์ •์ œํ•˜์—ฌ ์ถœ๋ ฅ.

  4. ๋ฐ˜๋ณต๋ฌธ์„ ์‚ฌ์šฉํ•˜๋˜, ๋ฐ˜๋ณต์˜ ์ข…๋ฃŒ๋ฅผ ์•Œ๋ ค์ฃผ๋Š” โ€œexitโ€ ๋ฌธ์ž์—ด์„ ์ž…๋ ฅํ•˜๊ธฐ ์ „๊นŒ์ง€ ๋ฌดํ•œ์œผ๋กœ ๊ณ„์‚ฐ์„ ์ง„ํ–‰ํ•  ์ˆ˜ ์žˆ๋„๋ก ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ•˜๊ธฐ
    • ํ‚ค์›Œ๋“œ: ๋ฌดํ•œ ๋ฐ˜๋ณต, ์ˆ˜์ •(์ฒ˜์Œ๋ถ€ํ„ฐ๊ฐ€ ์•„๋‹Œ ์Šคํ…๋ณ„๋กœ ์ง„ํ–‰ํ•˜๋ฉฐ ์ˆ˜์ •)
    • ๋ฐ˜๋ณต๋ฌธ: for, which

calculatorLevel2 ํด๋ž˜์Šค๋ฅผ ์ ์šฉํ•ด ๊ธฐ๋ณธ์ ์ธ ์—ฐ์‚ฐ์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ๋Š” ๊ณ„์‚ฐ๊ธฐ ๋งŒ๋“ค๊ธฐ.

  1. ์‚ฌ์น™์—ฐ์‚ฐ์„ ์ˆ˜ํ–‰ ํ›„, ๊ฒฐ๊ณผ๊ฐ’ ๋ฐ˜ํ™˜ ๋ฉ”์„œ๋“œ ๊ตฌํ˜„ & ์—ฐ์‚ฐ ๊ฒฐ๊ณผ๋ฅผ ์ €์žฅํ•˜๋Š” ์ปฌ๋ ‰์…˜ ํƒ€์ž… ํ•„๋“œ๋ฅผ ๊ฐ€์ง„ Calculator ํด๋ž˜์Šค๋ฅผ ์ƒ์„ฑ.

  2. calculatorLeve1์—์„œ ๊ตฌํ˜„ํ•œ App ํด๋ž˜์Šค์˜ main ๋ฉ”์„œ๋“œ์— Calculator ํด๋ž˜์Šค๊ฐ€ ํ™œ์šฉ๋  ์ˆ˜ ์žˆ๋„๋ก ์ˆ˜์ •

  3. App ํด๋ž˜์Šค์˜ main ๋ฉ”์„œ๋“œ์—์„œ Calculator ํด๋ž˜์Šค์˜ ์—ฐ์‚ฐ ๊ฒฐ๊ณผ๋ฅผ ์ €์žฅํ•˜๊ณ  ์žˆ๋Š” ์ปฌ๋ ‰์…˜ ํ•„๋“œ์— ์ง์ ‘ ์ ‘๊ทผํ•˜์ง€ ๋ชปํ•˜๋„๋ก ์ˆ˜์ •
    • ํ‚ค์›Œ๋“œ: ์บก์Аํ™”

  4. Calculator ํด๋ž˜์Šค์— ์ €์žฅ๋œ ์—ฐ์‚ฐ ๊ฒฐ๊ณผ๋“ค ์ค‘ ๊ฐ€์žฅ ๋จผ์ € ์ €์žฅ๋œ ๋ฐ์ดํ„ฐ๋ฅผ ์‚ญ์ œํ•˜๋Š” ๊ธฐ๋Šฅ์„ ๊ฐ€์ง„ ๋ฉ”์„œ๋“œ๋ฅผ ๊ตฌํ˜„ํ•œ ํ›„ App ํด๋ž˜์Šค์˜ main ๋ฉ”์„œ๋“œ์— ์‚ญ์ œ ๋ฉ”์„œ๋“œ๊ฐ€ ํ™œ์šฉ๋  ์ˆ˜ ์žˆ๋„๋ก ์ˆ˜์ •
    • ํ‚ค์›Œ๋“œ: ์ปฌ๋ ‰์…˜, "๊ฐ’์„ ๋„ฃ๊ณ  ์ œ๊ฑฐํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ดํ•ดํ•œ๋‹ค"

calculatorLevel3 Enum, ์ œ๋„ค๋ฆญ, ๋žŒ๋‹ค & ์ŠคํŠธ๋ฆผ์„ ์ดํ•ดํ•œ ๊ณ„์‚ฐ๊ธฐ ๋งŒ๋“ค๊ธฐ

  1. Enum ํƒ€์ž…์„ ํ™œ์šฉํ•˜์—ฌ ์—ฐ์‚ฐ์ž๋ฅผ ๊ด€๋ฆฌํ•˜๊ณ  ์ด๋ฅผ ์‚ฌ์น™์—ฐ์‚ฐ ๊ณ„์‚ฐ๊ธฐ ArithmeticCalculator ํด๋ž˜์Šค์— ํ™œ์šฉ

  2. ์‹ค์ˆ˜, ์ฆ‰ double ํƒ€์ž…์˜ ๊ฐ’์„ ์ „๋‹ฌ ๋ฐ›์•„๋„ ์—ฐ์‚ฐ์ด ์ˆ˜ํ–‰ํ•˜๋„๋ก ๋งŒ๋“ค๊ธฐ
    • ํ‚ค์›Œ๋“œ: ์ œ๋„ค๋ฆญ, ํ”ผ์—ฐ์‚ฐ์ž๋ฅผ ์—ฌ๋Ÿฌ ํƒ€์ž…์œผ๋กœ ๋ฐ›์„ ์ˆ˜ ์žˆ๋„๋ก ๊ธฐ๋Šฅ์„ ํ™•์žฅ

  3. ์ €์žฅ๋œ ์—ฐ์‚ฐ ๊ฒฐ๊ณผ๋“ค ์ค‘ Scanner๋กœ ์ž…๋ ฅ๋ฐ›์€ ๊ฐ’๋ณด๋‹ค ํฐ ๊ฒฐ๊ณผ๊ฐ’ ๋“ค์„ ์ถœ๋ ฅ
    • ArithmeticCalculator ํด๋ž˜์Šค์— ์œ„ ์š”๊ตฌ์‚ฌํ•ญ์„ ๋งŒ์กฑํ•˜๋Š” ์กฐํšŒ ๋ฉ”์„œ๋“œ๋ฅผ ๊ตฌํ˜„
    • ํ•ด๋‹น ๋ฉ”์„œ๋“œ๋ฅผ ๊ตฌํ˜„ํ•  ๋•Œ Lambda & Stream์„ ํ™œ์šฉ
    • ํ‚ค์›Œ๋“œ: ๋žŒ๋‹ค, ์ŠคํŠธ๋ฆผ

P.S.

calculatorLevel1์˜ ๊ฒฝ์šฐ Calculator.java๋งŒ์„ ๋ณด๋ฉด ๋˜๋ฉฐ, calculatorLevel3์—์„œ OperatorTypeEx์˜ ๊ฒฝ์šฐ util์˜ BiFuntion์„ ์‹œ๋„ ํ•ด๋ณด๋ ค ํ–ˆ๋˜๊ฒƒ์ด๋‹ˆ ์‹ค ์‚ฌ์šฉ์€ OperatorType์ด๋‹ค.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages