-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Done #1736
base: master
Are you sure you want to change the base?
Done #1736
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.
Hello! 😊 It looks like you're almost there, but there are a couple of critical issues that need to be addressed to meet the core requirements of the task:
-
Ball Class: The
Ball
class needs a constructor to initialize thecolor
andnumber
fields. This is essential for creatingBall
objects correctly. -
Lottery Class: The
getRandomBall()
method should return aBall
object instead of anint
. It should create aBall
with a random color and number, and return this object.
These changes are crucial for the functionality of your code. Once you make these adjustments, your solution will be in great shape! Keep up the good work, and don't hesitate to reach out if you need further assistance. 🌟
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review
button in the Reviewers tab.
return null; | ||
int index = new Random().nextInt(Colors.values().length); | ||
Colors color = Colors.values()[index]; | ||
return String.valueOf(color); |
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.
Instead of using String.valueOf(color)
, use color.name()
to get the string representation of the enum constant. This is a more reliable method as per the checklist guidelines.
public int getRandomBall() { | ||
System.out.println(colorSupplier.getRandomColor()); | ||
int number = random.nextInt(MAX_VALUE); | ||
return 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.
The getRandomBall
method should return a Ball
object instead of an int
. You need to create a new Ball
instance using the random color and number, and return that instance. This aligns with the task requirement to create and return a ball with both color and 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.
Review Summary
Great effort on implementing the Application
, ColorSupplier
, and Colors
classes! 🎉 However, there are a few critical issues that need attention:
-
Ball Class Constructor: The
Ball
class currently lacks a constructor to initialize thecolor
andnumber
fields. Adding a constructor that takes these parameters is essential for creatingBall
objects with the necessary attributes. -
Lottery Class
getRandomBall
Method: ThegetRandomBall()
method should return aBall
object instead of anint
. Ensure that this method creates aBall
with a random color and number, and returns this object. Additionally, theBall
instance should not be a field in theLottery
class; instead, create a newBall
instance within thegetRandomBall()
method.
These changes are crucial for the functionality of your code. Although the decision is to APPROVE this pull request to help you move forward with your learning, please review the comments and address these issues to improve your code. Keep up the good work and continue learning from these experiences! 🚀
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
|
||
public class Ball { | ||
private String color; | ||
private int 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.
The Ball
class needs a constructor to initialize the color
and number
fields. This is crucial for creating Ball
objects correctly. Consider adding a constructor that takes color
and number
as parameters.
public int getRandomBall() { | ||
System.out.println(colorSupplier.getRandomColor()); | ||
int number = random.nextInt(MAX_VALUE); | ||
return 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.
The getRandomBall()
method should return a Ball
object, not an int
. You need to create a new Ball
instance using the random color and number, and return this Ball
object.
|
||
private final Random random = new Random(); | ||
|
||
private final Ball ball = new Ball(); |
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.
The Ball
instance should not be a field in the Lottery
class. Instead, create a new Ball
instance within the getRandomBall()
method.
No description provided.