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

Classes created and tested #1725

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

MishaHMK
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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


Thank you for your hard work on this pull request! While your code is mostly well-implemented and meets many of the task requirements, there are a few critical issues that need to be addressed before we can approve it:

  1. Static Method Usage: The getRandomBall method in the Lottery class should not rely on a static method approach by accepting parameters like color and range. Instead, these should be generated internally, adhering to the task requirements.

  2. Access Modifiers: It's important to specify access modifiers for the Lottery class and its methods to ensure proper encapsulation and maintainability.

  3. Magic Numbers: The use of magic numbers, such as the number range (100) and the number of balls to create (3), should be avoided. Defining them as constants will enhance code readability and maintainability.

  4. Redundant Parameters: The getRandomBall method should generate the color internally using the ColorSupplier class, rather than accepting it as a parameter.

Please address these issues to ensure the code fully meets the task requirements. Once these changes are made, your code will be in great shape! Keep up the great work, and I'm confident you'll nail it with these adjustments! 😊

✨ 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.

public class Application {
public static void main(String[] args) {
// create three balls using class Lottery and print information about them in console
int ballsToCreate = 3;

Choose a reason for hiding this comment

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

Consider defining ballsToCreate as a constant, as it is a magic number. This will improve code readability and maintainability. For example, you can define it as private static final int BALLS_TO_CREATE = 3;.

public class Application {
public static void main(String[] args) {
// create three balls using class Lottery and print information about them in console
int ballsToCreate = 3;
int numberRange = 100;

Choose a reason for hiding this comment

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

Similarly, numberRange should be defined as a constant to avoid using magic numbers. Define it as private static final int NUMBER_RANGE = 100;.

public class ColorSupplier {
public String getRandomColor() {
return null;
int randomPosition = new Random().nextInt(Colors.values().length);
return Colors.values()[randomPosition].toString();

Choose a reason for hiding this comment

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

Instead of using toString(), use the name() method to get the string representation of the enum constant. This is a more reliable approach as per the checklist guidelines.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Thank you for your submission! 🎉 Your code demonstrates a solid understanding of the task requirements, and you've made good progress. However, there are a few critical issues that need to be addressed to ensure your code fully aligns with the task constraints:

  1. getRandomBall Method: This method should not accept parameters like color and range. Instead, it should internally generate a random color using the ColorSupplier class and use a predefined constant for the range. This is crucial for adhering to the task requirements.

  2. Magic Numbers: Avoid using magic numbers such as 100 for the number range. Define these as constants to enhance readability and maintainability.

  3. Naming Conventions: Ensure that constants are named using uppercase letters with underscores, such as NUMBER and RANGE, to follow Java naming conventions.

  4. Access Modifiers: Specify access modifiers for your classes and methods to ensure proper encapsulation and code clarity.

Please review the comments and make the necessary improvements. Addressing these issues will help you avoid similar problems in the future and enhance your coding skills. Keep up the great work, and continue learning from your experiences! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

Comment on lines +7 to +8
final int Number = 3;
final int Range = 100;

Choose a reason for hiding this comment

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

The constants Number and Range should be named using uppercase letters with underscores as separators, following Java naming conventions for constants. Consider renaming them to NUMBER and RANGE.

Ball[] result = new Ball[Number];

for (int i = 0; i < Number; i++) {
result[i] = lottery.getRandomBall(colorSupplier.getRandomColor(), Range);

Choose a reason for hiding this comment

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

The getRandomBall method should not accept parameters like color and range. Instead, it should internally generate these values. This is a critical issue as it does not adhere to the task requirements.

import java.util.Random;

public class Lottery {
public Ball getRandomBall(String color, int range) {

Choose a reason for hiding this comment

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

The getRandomBall method should not accept color and range as parameters. Instead, it should internally generate a random color using the ColorSupplier class and use a predefined constant for the range. This change is necessary to adhere to the task requirements.

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.

2 participants