[Step2]: ๐ 2๋จ๊ณ - ์ง๋ขฐ ์ฐพ๊ธฐ(์ง๋ขฐ ๊ฐ์)#414
Conversation
namjackson
left a comment
There was a problem hiding this comment.
์๋
ํ์ธ์ ์คํ๋!
2๋จ๊ณ ๊ณ ์ํ์
จ์ต๋๋ค,
๋ช๊ฐ์ง ์ฝ๋ฉํธ ๋จ๊ฒผ์ผ๋, ํ์ธํด์ฃผ์ธ์ :)
| if (minePositions.contains(position)) return Mine() | ||
| return NormalPedal() |
There was a problem hiding this comment.
| if (minePositions.contains(position)) return Mine() | |
| return NormalPedal() | |
| if (minePositions.contains(position)) Mine() else NormalPedal() |
๋ ๊ฐ๋จํ ์ฌ์ฉํด๋ณด์์!
| } | ||
|
|
||
| companion object { | ||
| private const val VALID_MESSAGE: String = "์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค." |
There was a problem hiding this comment.
๊ตฌ์ฒด์ ์ผ๋ก ์ด๋ค ์๋ฌ์ธ์ง ํ๊ธฐํ๋ฉด ์ด๋จ๊น์?
| return (x - 1..x + 1).flatMap { xVal -> | ||
| (y - 1..y + 1).map { yVal -> Position(xVal, yVal) } |
There was a problem hiding this comment.
x - 1, x - 1, y+1,y-1 ๋ฑ์ด ๋ฌด์์ ์๋ฏธํ ๊น์?
๋ฐ๋ก ๊ฐ์ฒด๋ฅผ ๊ด๋ฆฌํด๋ณด๋ฉด ์ด๋จ๊น์?
|
|
||
| class Mine : Pedal | ||
| class Mine( | ||
| override var mark: Mark? = Mark("*") |
There was a problem hiding this comment.
var ๋ก ์ ์ํ ์ด์ ๊ฐ ์์๊น์?
์ธ๋ถ์์ ์ฝ๊ฒ ๋ณ๊ฒฝ์ด ๊ฐ๋ฅํ ๊ตฌ์กฐ๋ค์!
|
|
||
| sealed interface Pedal { | ||
| } No newline at end of file | ||
| var mark: Mark? |
There was a problem hiding this comment.
nullable ๋ณ์๋ก ์ ์ ํ ์ด์ ๊ฐ ์์๊น์?
๋ ๋ถ๋ณ๊ฐ์ฒด๋ก ๋ง๋ค์ด๋ณด๋๊ฑด ์ด๋จ๊น์?
|
|
||
| } | ||
|
|
||
| fun List<Position>.toPositions(): Positions = Positions(this) No newline at end of file |
There was a problem hiding this comment.
์ค์ ์ต์
์ ํ์ฑํํ์ฌ EOF ๊ฒฝ๊ณ ๋ฅผ ์์ ์ฃผ์๋ฉด ์ข์๊ฑฐ๊ฐ์์!
(File > Preferences > Editor > General > Ensure every saved file ends with a line break )
| val pedals = field[position.toRow()] | ||
| require(pedals != null) { VALID_MESSAGE } | ||
|
|
||
| val pedal = pedals.get(position.x) |
There was a problem hiding this comment.
position.x ์ ํด๋นํ๋ ๊ฐ์ด ์์ผ๋ฉด ์ด๋ค์ผ์ด ์ผ์ด๋ ๊น์/
| positionFactory.generateMinePositions(size, mine) | ||
| ) | ||
|
|
||
| MarkGenerator.markGeneration(field) |
There was a problem hiding this comment.
ํ๋ผ๋ฏธํฐ๋ก ์ ๋ฌ๋ field๊ฐ MarkGenerator๋ด๋ถ์์ ๋ณ๊ฒฝ์ด ๋๋ค์!
markGeneration๋ฅผ ํตํด field๊ฐ ๋ณ๊ฒฝ๋ ์ ์๋ค๋ ์ ์ ์๊ฐํ ์ ์์๊น์?
๊ณ ๋ฏผํด๋ณด๋ฉด ์ข์๊ฑฐ๊ฐ์์!
|
|
||
| outputManager.printStartGame() | ||
| outputManager.printField(field) | ||
| } |
There was a problem hiding this comment.
MineGame์ ์ฌ์ค์ Controller ์ญํ ์ ํด์ฃผ๊ณ ์์ด์,
Controller์ View์์ ์ํธ์์ฉ์ ์ฑ
์์ ๊ฐ์ก๋ค๊ณ ์๊ฐ์ด ๋ค์ด์,
๊ทธ๋ ๋ค๋ฉด MineGame๋ด์์, ์ง๋ขฐ๋ฅผ ์์ฑํ๊ณ , markํ๋ ๋น์ฆ๋์ค๋ก์ง์ ๋ถ๋ฆฌํด๋ณด๋ฉด ์ด๋จ๊น์?
์๋ ํ์ธ์ ๋ฆฌ๋ทฐ์ด๋!!
๊ฐ์ ์ข ๋ฃ ํ์๋ ๋ฆฌ๋ทฐํด์ฃผ์ ๋ค๋ ๊ทธ์ ๊ฐ์ฌํ ๋ฐ๋ฆ์ ๋๋ค ๐
์ด๋ฒ 2๋จ๊ณ ๋ฆฌ๋ทฐ๋ ์ ๋ถํ๋๋ฆฝ๋๋ค!!!