generated from mate-academy/jv-homework-template
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package core.basesyntax; | ||
|
||
public class Ball { | ||
|
||
private String color; | ||
private int number; | ||
|
||
public void setColor(String color) { | ||
this.color = color; | ||
} | ||
|
||
public String getColor() { | ||
return color; | ||
} | ||
|
||
public void setNumber(int number) { | ||
this.number = number; | ||
} | ||
|
||
public int getNumber() { | ||
return number; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
|
||
return "Ball: " + "color = " + color + ", " + "number = " + number; | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
package core.basesyntax; | ||
|
||
import java.util.Random; | ||
|
||
public class ColorSupplier { | ||
String randomColor = getRandomColor(); | ||
|
||
public String getRandomColor() { | ||
return null; | ||
int index = new Random().nextInt(Colors.values().length); | ||
return String.valueOf(Colors.values()[index]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package core.basesyntax; | ||
|
||
public enum Colors { | ||
GREEN, | ||
RED, | ||
YELLOW, | ||
ORANGE, | ||
BLACK, | ||
WHITE, | ||
BLUE, | ||
GRAY, | ||
VIOLET, | ||
BROWN | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package core.basesyntax; | ||
|
||
import java.util.Random; | ||
|
||
public class Lottery extends ColorSupplier { | ||
Random random = new Random(); | ||
int randomInt = random.nextInt(100); | ||
|
||
public Ball getRandomBall() { | ||
Ball randomBall = new Ball(); | ||
randomBall.setColor(randomColor); | ||
randomBall.setNumber(randomInt); | ||
return randomBall; | ||
} | ||
} |