-
Notifications
You must be signed in to change notification settings - Fork 1.5k
completed tasks #1555
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
base: master
Are you sure you want to change the base?
completed tasks #1555
Changes from 4 commits
a4fe25a
e38af7d
584a6f9
43ff6bf
13df86d
1475cf1
c6a01a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package ball.characteristics; | ||
|
||
public class Ball { | ||
private final int number; | ||
private final String color; | ||
|
||
public Ball(int number, String color) { | ||
this.color = color; | ||
this.number = number; | ||
} | ||
|
||
public Ball(Ball ball) { | ||
this.color = ball.color; | ||
this.number = ball.number; | ||
} | ||
|
||
public String getColor() { | ||
return color; | ||
} | ||
|
||
public int getNumber() { | ||
return number; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "The color of the ball is " + getColor() | ||
+ " and the number of the ball is " + getNumber(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package ball.characteristics; | ||
|
||
public enum Color { | ||
RED, | ||
GREEN, | ||
PINK, | ||
IVORY, | ||
BLUE, | ||
PURPLE, | ||
YELLOW, | ||
ORANGE | ||
} |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -1,7 +1,14 @@ | ||||||||
package core.basesyntax; | ||||||||
|
||||||||
import ball.characteristics.Ball; | ||||||||
|
||||||||
public class Application { | ||||||||
public static void main(String[] args) { | ||||||||
// create three balls using class Lottery and print information about them in console | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't add redundant empty lines to your code. There's no need for an empty line after the main method signature. |
||||||||
for (int i = 0; i < 3; i++) { | ||||||||
|
||||||||
Lottery lottery = new Lottery(); | ||||||||
|
||||||||
Ball ball = new Ball(lottery.getRandomBall()); | ||||||||
System.out.println(ball); | ||||||||
|
Ball ball = new Ball(lottery.getRandomBall()); | |
System.out.println(ball); | |
System.out.println(lottery.getRandomBall())); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
package core.basesyntax; | ||
|
||
import ball.characteristics.Color; | ||
import java.util.Random; | ||
|
||
public class ColorSupplier { | ||
private static final Random random = new Random(); | ||
|
||
public String getRandomColor() { | ||
return null; | ||
int index = random.nextInt(Color.values().length); | ||
return Color.values()[index].name(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,16 @@ | ||||||
package core.basesyntax; | ||||||
|
||||||
import ball.characteristics.Ball; | ||||||
import java.util.Random; | ||||||
|
||||||
public class Lottery { | ||||||
static final int BORDER = 100; | ||||||
|
static final int BORDER = 100; | |
private static final int BORDER = 100; |
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 toString() method should return a string that represents the entire Ball object, not just the color. Consider including both the number and the color in the returned string.