Skip to content

Step4 - Lotto (Manual) #1158

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

Open
wants to merge 2 commits into
base: mingyum-kim
Choose a base branch
from
Open

Conversation

Mingyum-Kim
Copy link

Hello, Brie. How are you 😆

I completed to add new feature in Lotto mission, and apply your comment in previous PR.
I hope you have great weekend.

Thank you 😄

@Mingyum-Kim Mingyum-Kim changed the base branch from main to mingyum-kim April 11, 2025 18:47
Copy link

@byjo byjo left a comment

Choose a reason for hiding this comment

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

Hi Mingyum, how are you? 🤗

You also did a great job on this step!
The code is already well-structured and tested, but since this is the final stage, it would be great to do a bit of cleanup before wrapping up.
I've left a few comments with suggestions for improvement.

You're almost there — keep it up and finish strong! 💪

Comment on lines +15 to 17
val matches = ticket.checkMatches(winningNumbers)
val bonusMatches = ticket.checkBonusMatches(winningNumbers)
statistics.add(matches, bonusMatches)
Copy link

Choose a reason for hiding this comment

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

Continue to #1156 (comment):

Oh, my mistake 🥲 I explained it inappropriately — sorry for the confusion.
What I actually meant to ask was: "Why do we check both matches and bonus matches separately?"

Since both are needed to determine the prize, wouldn’t it make more sense to treat them as a single match result?
Is there a way we could express this in a more cohesive?

@@ -1,12 +1,24 @@
package lotto.domain

import lotto.controller.WinningNumbers

class Ticket(val lottoNumber: Set<LottoNumber>) {
constructor() : this(generateLottoNumber())
Copy link

Choose a reason for hiding this comment

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

It's a nice approach to distinguish between generating a ticket randomly and manually.
However, I think the current constructor doesn't clearly convey that intent.
How about using a factory function instead?

Here’s a reference you might find helpful:

val tickets = LottoShop().purchase(purchaseAmount)
resultView.printTickets(tickets)
val manualTickets = inputView.enterManualTickets()
val tickets = LottoShop().purchase(purchaseAmount, manualTickets)
Copy link

Choose a reason for hiding this comment

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

When we purchase the tickets, a new instance of LottoShop is created each time.
Do you think that's necessary? How else could we handle that?

Here’s a reference you might find helpful:


(+) Similarly, LottoNumber is a value object with a fixed range of values.
It might be worth thinking about how instances are managed.
I recommend revisiting what we covered in the last feedback session!

throw IllegalArgumentException("Please enter $AMOUNT_OF_NUMBER_FOR_TICKET numbers")
}
}

constructor(input: List<Int>) : this(input.map { LottoNumber(it) }.toSet())
Copy link

Choose a reason for hiding this comment

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

Before merging, it might be good to double-check if the class layout follows the recommended order across the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants