-
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
added solution #1281
base: master
Are you sure you want to change the base?
added solution #1281
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.
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
Lottery ballOne = new Lottery(); | ||
Lottery ballTwo = new Lottery(); | ||
Lottery ballThree = new Lottery(); |
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.
Lottery is lottery, Ball is ball. We need 1 Lottery and 3 Balls
public class Ball { | ||
|
||
private String 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.
@@ -0,0 +1,10 @@ | |||
package core.basesyntax; | |||
|
|||
public enum Colors { |
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.
public enum Colors { | |
public enum Color { |
public class ColorSupplier { | ||
public String getRandomColor() { | ||
return null; | ||
Random random = new Random(); |
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.
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.
Generally good work, but please read checklist carefully
package core.basesyntax; | ||
|
||
public class Ball { | ||
private String 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.
Use Enum Color that you created instead of regular String
|
||
public class Lottery { | ||
|
||
Ball getRandomBall() { |
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.
Add access modifier for this method
System.out.println(lottery.getRandomBall().toString()); | ||
System.out.println(lottery.getRandomBall().toString()); | ||
System.out.println(lottery.getRandomBall().toString()); |
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.
public class Lottery { | ||
|
||
Ball getRandomBall() { | ||
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.
Move Ball, Color and Random instances creation out of this method - create them at the class level, so they can be reusable. Don't foerget access modifier for these fields once they are at the class level
private Ball ball = new Ball();
public Ball getRandomBall() {
...
}
ball.setColor(color); | ||
|
||
Random random = new Random(); | ||
int ballIndex = random.nextInt(101); |
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.
- Optimized Lottery - Added loops in Application - Added access modifiers
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.
Great!
No description provided.