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

LotterySolution #1293

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

Conversation

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

Java Cl checks failed. Before making a Pull Request (or a new commit to an already existing PR), you need to write the mvn clean package command in the terminal and make sure that all checks pass. After that, the mentor will be able to review the homework

image

@VitaliyProgrammer
Copy link
Author

Please, check my new commit "LotteryRemodeled"

//Creating type of color
public static Color getRandomColor() {

Random random = new Random();

Choose a reason for hiding this comment

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

random should be instantiated once and reused multiple times,

nor creating each time the getRandomColor method is invoked

return null;

//Creating type of color
public static Color getRandomColor() {

Choose a reason for hiding this comment

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

Dont use static

Suggested change
public static Color getRandomColor() {
public Color getRandomColor() {

public class Lottery {
public static Ball getRandomBall() {
String colorRandom = ColorSupplier.getRandomColor().toString(); //1
Random random = new Random();

Choose a reason for hiding this comment

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

random should be instantiated once

public static Ball getRandomBall() {
String colorRandom = ColorSupplier.getRandomColor().toString(); //1
Random random = new Random();
int numberRandom = random.nextInt(100) + 1; //2

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 using magic numbers

should be constant with proper name

Suggested change
int numberRandom = random.nextInt(100) + 1; //2
int numberRandom = random.nextInt(100) + 1; //2

import java.util.Random;

public class Lottery {
public static Ball getRandomBall() {

Choose a reason for hiding this comment

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

Dont use static

Suggested change
public static Ball getRandomBall() {
public Ball getRandomBall() {

@VitaliyProgrammer
Copy link
Author

VitaliyProgrammer commented Jan 1, 2024

Please, check my fixed commit "Fixed task balls"..

Comment on lines 3 to 4
public class Ball {

private Color color;
Copy link

Choose a reason for hiding this comment

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

image

Comment on lines 20 to 18
+ '}';

}
Copy link

Choose a reason for hiding this comment

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

Suggested change
+ '}';
}
+ '}';
}

public Ball(Color color, int number) {

this.color = color;
Copy link

Choose a reason for hiding this comment

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

image

Comment on lines 6 to 12

private final Color[] colors = Color.values();
private final Random random = new Random();

public Color getRandomColor() {

return colors[random.nextInt(colors.length)];
Copy link

Choose a reason for hiding this comment

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

image

@VitaliyProgrammer VitaliyProgrammer force-pushed the new_branch branch 6 times, most recently from 7792ffa to 3e32932 Compare January 2, 2024 13:52
@VitaliyProgrammer VitaliyProgrammer force-pushed the new_branch branch 2 times, most recently from d1b3ea3 to 3e32932 Compare January 2, 2024 14:55
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