Skip to content
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

[STEP-2] 로또(자동) #1054

Open
wants to merge 15 commits into
base: 0703kyj
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[STEP-2] 로또 추가
0703kyj committed Nov 23, 2024
commit 4743ea7f4c9b6e9a5a14772083b0a752fb55a05a
2 changes: 1 addition & 1 deletion lotto/README.md
Copy link
Member

Choose a reason for hiding this comment

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

기능 목록을 잘 만들어주셨네요 👍
이렇게 작성하신 기능 목록이 결국에는 커밋 단위, 테스트 시나리오까지 이어지게 되는데요,
특히 TDD를 하시는 과정에서 객체 설계 및 “어떤 시나리오를 테스트해야 하지“에 대한 본인만의 답을 만들기에도 도움이 될거예요.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Lotto

- [ ] 로또 구입 금액을 입력하면 구입 금액에 해당하는 로또를 발급해야 한다.
- [x] 로또 구입 금액을 입력하면 구입 금액에 해당하는 로또를 발급해야 한다.
- [x] 로또 1장의 가격은 1000원이다.
- [x] 최소 구매금액은 1000원이다.
- [x] 구매금액의 최소 단위는 1000원이다.
4 changes: 2 additions & 2 deletions lotto/src/main/kotlin/lotto/Main.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package lotto

import lotto.domain.LottoPurchaseAmount
import lotto.domain.User
import lotto.domain.LottoUser
import lotto.view.InputView

fun main() {
val lottoPurchaseAmount = LottoPurchaseAmount(InputView.inputPurchaseAmount())
val user = User(lottoPurchaseAmount)
val lottoUser = LottoUser(lottoPurchaseAmount)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package lotto.domain

class User(
class LottoUser(
val lottoPurchaseAmount: LottoPurchaseAmount,
) {
private val lottoCount = lottoPurchaseAmount.calculateLottoCount()
Original file line number Diff line number Diff line change
@@ -3,23 +3,23 @@ package lotto.domain
import io.kotest.matchers.shouldBe
import org.junit.jupiter.api.Test

class UserTest {
class LottoUserTest {
@Test
fun `사용자는 구매금액을 가지고 있는다`() {
val lottoPurchaseAmount = LottoPurchaseAmount(1000)

val user = User(lottoPurchaseAmount)
val lottoUser = LottoUser(lottoPurchaseAmount)

user.lottoPurchaseAmount shouldBe lottoPurchaseAmount
lottoUser.lottoPurchaseAmount shouldBe lottoPurchaseAmount
}

@Test
fun `사용자는 지불한 금액만큼의 로또를 가지고 있는다`() {
val lottoPurchaseAmount = LottoPurchaseAmount(1000)

val user = User(lottoPurchaseAmount)
val lottoUser = LottoUser(lottoPurchaseAmount)

user.lotteries.size shouldBe lottoPurchaseAmount.calculateLottoCount()
lottoUser.lotteries.size shouldBe lottoPurchaseAmount.calculateLottoCount()
}

@Test