-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
π 1λ¨κ³ - λ¬Έμμ΄ λ§μ κ³μ°κΈ° #1069
base: aimbe
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ νΈλ μλ
νμΈμ.
λ‘λ λ―Έμ
μ ν¨κ»νκ²λ κΉκ²½λ‘μ
λλ€. π€
1λ¨κ³ ꡬν μν΄μ£Όμ
¨μ΅λλ€. ππ
λͺλͺ μ½λ©νΈ λ¨κ²¨λμμΌλ νμΈν΄μ λ°μ λΆνλ릴κ²μ. π
λ―Έμ
μ§ννμλ©΄μ μ΄λ €μ΄λΆλΆ μκΈ°λ©΄ μΈμ λ μ§ DM μ£ΌμΈμ. π
#### κΈ°λ₯ μꡬμ¬ν | ||
|
||
- [ ] κΈ°λ³Έ ꡬλΆμλ₯Ό μ΄μ©ν λ¬Έμμ΄ λΆλ¦¬ λ° λ§μ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
κΈ°λ₯ ꡬν λͺ©λ‘νλ₯Ό μμ± ππ―
ν΄λΉ κΈ°λ₯μ΄ κ΅¬νλλ©΄ κΈ°λ₯ ꡬν λͺ©λ‘νλ κ°μ΄ μ λ°μ΄νΈν΄μ 컀λ°νλ©΄ μ‘°κΈ λ μ΄μμλ λ¬Έμκ°λ κ² κ°μμ. π€
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ μꡬ λͺ μΈλ₯Ό μ λ°μ΄νΈ νλκ²μ κΉλΉ‘νλ€μ! γ γ 체ν¬νκ² μ΅λλ€ κ°μ¬ν©λλ€!
@@ -0,0 +1,6 @@ | |||
package calculator | |||
|
|||
interface DelimiterStrategy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ€.. μ λ΅ ν¨ν΄μ νμ©νμ¬ κΈ°λ³Έ ꡬλΆμ
(μΌν, μ½λ‘ )μ 컀μ€ν
ꡬλΆμ
λ₯Ό ꡬννμ
¨κ΅°μ? ππ―
μΆν μλ‘μ΄ κ΅¬λΆμ μ μ±
μ΄ μκΈ°λλΌλ Strategyλ₯Ό νλ λ ꡬνν΄μ£ΌκΈ°λ§νλ©΄ μ½κ² λμν μ μκ² κ΅°μ? π
|
||
class CustomDelimiterStrategy : DelimiterStrategy { | ||
override fun supports(text: String): Boolean { | ||
return text.startsWith("//") && text.contains("\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ.. μ΄ λΆλΆμ μλμ λ¬λ¦¬ λμν μ μλ μ¬μ§κ° μμ΄λ³΄μ
λλ€. π€
μ΄ μΌμ΄μ€λ κ°λ₯νλ©΄ μ κ·μμ νμ©ν΄λ³΄λ©΄ μ΄λ¨κΉμ? π
λ―Έμ μκ° νμ΄μ§μμλ 컀μ€ν ꡬλΆμλ₯Ό μλμ κ°μ΄ μ μνκ³ μμ΄μ.
컀μ€ν ꡬλΆμλ λ¬Έμμ΄ μλΆλΆμ β//βμ β\nβ μ¬μ΄μ μμΉνλ λ¬Έμ
1κΈμλΌκ³ λͺ μν κ²μ μλμ§λ§, λ¬ΈμλΌκ±°λ μμ μ μΌμ΄μ€λ₯Ό μκ°νμ λ, ν κΈμκ° μλκ° μΆμ΄μ.
- λ―Έμ
μκ° νμ΄μ§μ μ
λ ₯ μμ :
//;\n1;2;3
- μ€λ₯κ° λ μ μλ μΌμ΄μ€1: '//;;\n1;2;3'
- μ€λ₯κ° λ μ μλ μΌμ΄μ€1: '//1;2;3\n'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ λ μ¬μ€ ꡬννλ©΄μ μμΈμ μΈ μΌμ΄μ€μ λμμ μνκ² λλ°..? μκ°μ νλ€κ°
μ£Όμ ꡬν λͺ©νκ° TDDλΌ μ‘κ³ μ κ²½μ λμΌλκ² κ°μ΅λλ€ γ
γ
μ κ·μ νμ©ν΄μ νλ² μ§νν΄λ³΄κ² μ΅λλ€!
val delimiter = text.substring(2, 3) | ||
return text.substring(4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ΄ μ½λλ₯Ό μ²μ보λ μ¬λμ΄λΌλ©΄ 2
, 3
, 4
μ κ°μ μ«μκ° μ΄λ€ μλ―Έλ₯Ό κ°μ§λμ§ μ΄ν΄νκΈ°κ° μ΄λ €μΈ κ² κ°μμ. π€
μλμ κΈμ μ°Έκ³ ν΄λ³΄μλ©΄ μ’μ κ² κ°μ΅λλ€. π
μλ―Έκ° λΆλΆλͺ ν λ§€μ§ λλ²λ₯Ό μμλ‘ μ μΈνλΌ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
λ΅ constantν΄λμ€ λ§λ€μ΄μ �맀μ§λλ² μμν νμ΅λλ€!
} | ||
|
||
override fun parse(text: String): List<Int> { | ||
return text.split("[,:]".toRegex()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pattern
κ³Ό κ°μ λΉμΌ κ°μ²΄μ μμ±μ 맀λ²ν νμ μμ΄ μμλ‘ λ―Έλ¦¬ μ μν΄λκ³ μ¬μ¬μ©νλ©΄ μ΄λ¨κΉμ? π
κ°μ²΄μ μμ±κ³Ό νκ΄΄ - λΆνμν κ°μ²΄ μμ±μ νΌνλΌ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ€ κ°μ¬ν©λλ€! γ γ μ°Έκ³ νκ² μ΅λλ€
DefaultDelimiterStrategy() | ||
) | ||
|
||
fun parse(text: String): List<Int> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
λ©μλ νλΌλ―Έν° μ΄λ¦μ μ‘°κΈ λ μλ―Έμκ² λ³κ²½ν΄λ³΄λ©΄ μ΄λ¨κΉμ? π€
λ¬Έμμ΄ λ§μ
κ³μ°κΈ°
λΌλ λλ©μΈμμ μ
λ ₯ λ°λ κ°μ 무μμΈκ°μ? κ·Έ μλ―Έκ° λλ¬λλ λ€μ΄λ°μ΄λ©΄ μ’μ κ² κ°μμ.
DefaultDelimiterStrategy() | ||
) | ||
|
||
fun parse(text: String): List<Int> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parse λ©μλμ λν ν μ€νΈλ μμ±ν΄λ³΄μλ©΄ μ΄λ¨κΉμ? π
return when { | ||
text.length == 1 -> listOf(text.toInt()) | ||
else -> parseWithStrategy(text) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
textμ κΈΈμ΄λ‘λ§ caseλ₯Ό ꡬλΆνμ€κ±°λΌλ©΄ μλμ κ°μ΄ λ³κ²½ν μλ μμ κ² κ°λ€μ. π
return when { | |
text.length == 1 -> listOf(text.toInt()) | |
else -> parseWithStrategy(text) | |
} | |
return when (text.length) { | |
1 -> listOf(text.toInt()) | |
else -> parseWithStrategy(text) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ κ·μμΌλ‘ νλ¨ λ‘μ§ λ³κ²½νλ©΄μ ν΄λΉ λ‘μ§λ€μ μμ΄μ‘μ§λ§, μΆν μ λ° μΌμ΄μ€ μμΌλ©΄ μ λ°μμΌλ‘ μ°λκ² κ°λ μ± λ μ’μ보μ΄λ€μ γ γ κ°μ¬ν©λλ€~
|
||
fun parse(text: String): List<Int> { | ||
return when { | ||
text.length == 1 -> listOf(text.toInt()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
text.length == 1
μ κ²½μ°μλ§ νλμ μ«μλ§ μΆμΆνλκ±°κ΅°μ? π€
λ§μ½ textκ° "11"
μ κ°μ΄ λμ리 μ«μκ° λ€μ΄μ€κ²λλ©΄ μ΄λ»κ² λλκ±ΈκΉμ?
@@ -0,0 +1,12 @@ | |||
package calculator | |||
|
|||
class NumberValidator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ§κΈμ²λΌ λ¬Έμμ΄ λ§μ
κ³μ°κΈ°
λΌλ λλ©μΈμ νμν Number λλ©μΈ λͺ¨λΈμ μΌλ°μ μΈ Numberλ λ¬λ¦¬ μμμ¬μΌνλ νΉμ§μ΄ μλλ°μ.
μμ κ°μΌλ‘λ μ΄λ° κ°μ νννλλ°μλ νκ³κ° μλλ°μ. π₯²
μμκ°μ ν¬μ₯ν¨μΌλ‘μ¨ λλ©μΈμ νΉνλ λλ©μΈ λͺ¨λΈμ μ§μ λ§λ€μ΄λ³΄μλ©΄ μ΄λ¨κΉμ? π
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
λ΅ Numbers λλ©μΈ λͺ¨λΈμ λν μΌκΈ 컬λ μ μμ± λ€ μ± μ λΆλ¦¬νμ΅λλ€!
μλ νμΈμ κ²½λ‘λ !οΏ½step1μ κ°μ²΄μ μ± μμ λΆλ¦¬νλ €κ³ μ€μ μ λμ΅λλ€!
μ΄λ² λ―Έμ μ λΆνλ립λλ€!