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

Homework #1247

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

Homework #1247

wants to merge 9 commits into from

Conversation

Kinereiko
Copy link

No description provided.

Copy link

@Rommelua Rommelua left a comment

Choose a reason for hiding this comment

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

Before you create PR with your homework, you need to go through the checklist under the task and correct all the points described there. The mentor will not check the work until the checklist points are corrected

@@ -3,5 +3,9 @@
public class Application {
public static void main(String[] args) {
// create three balls using class Lottery and print information about them in console
Lottery lottery = new Lottery();
for (int i = 0; i < 3; i++) {
System.out.println(lottery.getRandomBall().toString());

Choose a reason for hiding this comment

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

Suggested change
System.out.println(lottery.getRandomBall().toString());
System.out.println(lottery.getRandomBall());

public String getRandomColor() {
return null;
public Colors getRandomColor() {
int index = new Random().nextInt(Colors.values().length);

Choose a reason for hiding this comment

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

image

@@ -0,0 +1,11 @@
package core.basesyntax;

public enum Colors {

Choose a reason for hiding this comment

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

Suggested change
public enum Colors {
public enum Color {

public Ball getRandomBall() {
Ball randBall = new Ball();
randBall.setColor(supplier.getRandomColor());
randBall.setNumber(new Random().nextInt(100));

Choose a reason for hiding this comment

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

image

@Kinereiko Kinereiko requested a review from Rommelua November 16, 2023 12:26
public Ball getRandomBall() {
Ball randBall = new Ball();
randBall.setColor(supplier.getRandomColor());
randBall.setNumber(randNum.nextInt(100));

Choose a reason for hiding this comment

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

100 is a magic number.
Avoid direct use of magic numbers instead you should always make it constant with self-descriptive name.

Suggested change
randBall.setNumber(randNum.nextInt(100));
randBall.setNumber(randNum.nextInt(100));

@Kinereiko Kinereiko requested a review from sokimaaa November 16, 2023 20:27
import java.util.Random;

public class Lottery {
private static final int maxNumber = 100;

Choose a reason for hiding this comment

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

Suggested change
private static final int maxNumber = 100;
private static final int MAX_BALL_NUMBER = 100;

public class Lottery {
private static final int maxNumber = 100;
private final ColorSupplier supplier = new ColorSupplier();
private final Random randNum = new Random(100);

Choose a reason for hiding this comment

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

Suggested change
private final Random randNum = new Random(100);
private final Random random = new Random();

@Kinereiko Kinereiko requested a review from Rommelua November 17, 2023 12:54
public class Lottery {
private static final int MAX_BALL_NUMBER = 100;
private final ColorSupplier supplier = new ColorSupplier();
private final Random random = new Random(100);

Choose a reason for hiding this comment

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

you sent magic number, why if you have constant already?

Comment on lines 7 to 21
public Color getColor() {
return color;
}

public void setColor(Color color) {
this.color = color;
}

public int getNumber() {
return number;
}

public void setNumber(int number) {
this.number = number;
}

Choose a reason for hiding this comment

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

Better use constructor and you don`t to need getters an setters

package core.basesyntax;

public class Ball {
private Color color;

Choose a reason for hiding this comment

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

Use String for color

Comment on lines 8 to 10
public Color getRandomColor() {
int index = random.nextInt(Color.values().length);
return Color.values()[index];

Choose a reason for hiding this comment

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

return here String

@Kinereiko Kinereiko requested a review from Sanderfuck November 17, 2023 13:35
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.

4 participants