-
Notifications
You must be signed in to change notification settings - Fork 180
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λ¨κ³ - μ§λ’° μ°ΎκΈ°(그리기) #361
base: mins99
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.
μλ νμΈμ. μ§λ’°μ°ΎκΈ° λ―Έμ λμ μ λΆνλ립λλ€. ππ»
κ·Έλμ ν΄μ¨ λ―Έμ
λ€μμ νμ΅ν κ°λ
λ€μ΄ μ§λ’°μ°ΎκΈ°μμλ μ΄μ΄μ μ μ©λμΌ ν©λλ€.
λλ€ ν
μ€νΈ, μΆμν λ± λ°°μ λ κ²λ€μ κΈ°μ΅νλ©΄μ λ€μ κ³ λ―Ό ν΄ λ³΄λ©΄ μ’μ λ§ν λ΄μ©λ€μ λ¨κ²Όμ΅λλ€.
fun plantingMine(countOfMine: Int) { | ||
var mineCount = 0 | ||
|
||
while (mineCount < countOfMine) { | ||
val row = rows.getPosition() | ||
val col = cols.getPosition() | ||
|
||
mineCount = plantingResult(row, col, mineCount) | ||
} | ||
} |
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.
μΌλ°μ μΌλ‘ μκ°νμ λ, getPosition()
μ΄λΌλ ν¨μκ° λ¬΄μμ λ°νν κ²μ΄λΌκ³ μμΈ‘ν κΉμ?
κ³Όμ° λ¬΄μμ κ°μ λ°νν κ²μΌλ‘ κΈ°λν μ μμκΉμ?
μ λ κ·Έ μ΄μ μ ν, μ΄ μ΄λΌλ κ° κ°μ²΄κ° Position ? μ΄λΌλ μμΉλΌλ κ²μ΄ 무μμ μλ―Ένλ κ²μΈμ§ λΆν° μ΄ν΄κ° μ λμ§ μμ κ² κ°μμ.
μ΄λ ν x, y μ’νμ μ§λ’°λ₯Ό μ¬λλ€λ μν λ‘ λ§λ€μ΄ 보λ건 μ΄λ¨κΉμ?
// position μμΉμ μ§λ’°λ₯Ό μ¬λλ€.
fun mine(position: Position) { ... }
private fun plantingResult(row: Int, col: Int, mineCount: Int): Int { | ||
if (minefield[row][col] is Island) { | ||
minefield[row][col] = Mine() | ||
return mineCount + 1 | ||
} | ||
return mineCount | ||
} |
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. 5 x 5 ν¬κΈ°μ 보λλ₯Ό μ€λΉνλ€ // Minefield
2. μ§λ’°μ μμΉλ₯Ό νλ¨νλ€. // MineSweeperGame
3. μ§λ’°μ μμΉλ λλ€μΌλ‘ λ°μ μλ μκ³ , λͺ
μμ μΌλ‘ λ°μ μλ μλ€ (interface)
4. μ£Όμ΄μ§ μ§λ’°μ μμΉλ§νΌ μ§λ’°λ₯Ό μ¬λλ€. ( ??? )
interface Opening { | ||
val value: String | ||
} |
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.
cellμ κ²½μ° κ°λ₯ν μΌμ΄μ€κ° λΉμΉΈ λλ μ§λ’° λ‘ λμ΄μλ€ λ³΄λ μΈν°νμ΄μ€(Opening)λ₯Ό μ¬μ©νμ¬ μ μ°νκ² κ΅¬μ±
λΉμΉΈ, λλ μ§λ’°λΌλ μλ―Έκ° Opening μ΄λΌλ νμ
μΌλ‘ μ μ΄λ£¨μ΄μ Έ μμκΉμ?
Opening μ΄λΌλ κ²μ μ΄λ ν μν? μ²λΌ λκ»΄μ§μ§ μμκΉμ?
isOpening()
...
μ§λ’°μ°ΎκΈ°μ κΈ°λ³Έ κ²μ ꡬμ±μΌλ‘λ 보λ νμλ Nκ°μ μ
(Cell)μ΄ μ‘΄μ¬νλ€
μ νννκ³ λ ν©λλ€.
κ·Έλ λ€λ©΄ μ΄λ₯Ό λμ
ν΄ λ΄€μ λ 보λ νμλ Nκ°μ Openingμ΄ μ‘΄μ¬νλ€
λ‘ λΉκ΅ ν΄ λ³΄μ€ μ μμ΅λλ€.
@@ -0,0 +1,3 @@ | |||
package minesweeper.model.cell | |||
|
|||
data class Mine(override val value: String = "*") : Opening |
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.
"*"
μ μΆλ ₯νλ κ²μ UIμ κ΄μ¬μ¬ μ΄μ§ μμκΉμ?
κ°λ Ή μ§λ’°λ₯Ό λ³μ΄ μλ κ·Έλν½ λͺ¨μμ μ§λ’°λ‘ μΆλ ₯νλ€κ³ νλ©΄, λλ©μΈ λͺ¨λΈμ valueλ μλ¬΄λ° μν μ νμ§ λͺ»νκ² λ κ±°μμ.
plantingMines() | ||
} | ||
|
||
fun minefield(): Array<Array<Opening>> = minefield.minefield |
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.
μΌκΈμ»¬λ μ μ¬μ©μ view μμμ λ°μ΄ν°λ₯Ό κ°μ Έμ¬ λ
fun minefield(): Array<Array> = minefield.minefield μ κ°μ΄ ν λ² λ κΊΌλ΄κ² λλλ°,
νΉμ κ°μ²΄μ§ν₯μ μΌλ‘ λ μ’μ λ°©λ²μ΄ μλ€λ©΄ μλ €μ£Όμλ©΄ κ°μ¬νκ² μ΅λλ€! π
κ²°κ³Ό(λͺ¨λ μ
μ μΆλ ₯)μλ§ μ§μ€νλ λμ νμν κΈ°λ₯μ μκ² μ κ·Ό ν΄ λ³Ό μλ‘ μ’μ΅λλ€.
κ°λ Ή νκ³Ό μ΄μ ν¬κΈ°λ₯Ό μκ³ μμ λ μ°λ¦¬κ° μνλ κ²μ, "ν΄λΉ μμΉμ μλ μ
μ μλ €μ€" μ
λλ€.
fun getCellByPosition(position: Position): Cell { ... }
val position = Position(x, y)
val cell: Cell = getCellByPosition(position)
class Minefield( | ||
private val rows: Rows, | ||
private val cols: Cols, | ||
val minefield: Array<Array<Opening>> |
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.
Array<Array<Opening>>
νμ
μ΄λΌλ©΄, μ΄λ ν μμΉμ μ
μ μ κ·ΌνκΈ° μν΄ λ€μ λΆνμν μνκ° λ§μ΄ νμν μ μμ΅λλ€.
νΉμ μμΉλ₯Ό λ³΄λ€ ν¨μ¨μ μΌλ‘ μ κ·ΌνκΈ° μν μλ£κ΅¬μ‘°λ₯Ό κ³ λ € ν΄ λ³Ό μ μμ§ μμκΉμ?
μλ νμΈμ 리뷰μ΄λ!
λλμ΄ λ§μ§λ§ λ―Έμ μ§λ’°μ°ΎκΈ°κ° μμλμλ€μ~! νμ§λ§ λ§μ§λ§μ΄λΌκ³ μμ£Όνμ§ μκ³ μμ£Ό ν΄λ³΄κ² μ΅λλ€ πββοΈ
μ΄λ―Έ μκ³ μλ κ²μμ΄λΌ κ·Έλ°μ§ λΈλμμ λΉν΄μλ μμνκ² κ΅¬ννλκ² κ°μ΅λλ€
컀λ°μ 보μλ©΄ μμκ² μ§λ§ μμ²λκ² λ¨μνκ² κ΅¬ννλ€κ°.. μ‘°κΈ λ κ°μ²΄λ₯Ό λλ μ μμκ² κ°μμ(+ κ°μ²΄μ§ν₯ μν 체쑰 μμΉμ μ§ν€κ³ μ) λλμ΄λ³΄μμ΅λλ€!
μ°Έκ³ μ¬ν
ν¨ν€μ§ ꡬ쑰
κ³ λ―Όκ±°λ¦¬
μΌκΈμ»¬λ μ μ¬μ©μ view μμμ λ°μ΄ν°λ₯Ό κ°μ Έμ¬ λ
fun minefield(): Array<Array<Opening>> = minefield.minefield
μ κ°μ΄ ν λ² λ κΊΌλ΄κ² λλλ°,νΉμ κ°μ²΄μ§ν₯μ μΌλ‘ λ μ’μ λ°©λ²μ΄ μλ€λ©΄ μλ €μ£Όμλ©΄ κ°μ¬νκ² μ΅λλ€! π
μ΄μ¬ν ν΄λ³΄κ² μ΅λλ€! μ λΆνλ립λλ€~!