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.
created a lottery class with the getRandomBall method, which returns …
…ball.
- Loading branch information
1 parent
5631fad
commit 007329c
Showing
4 changed files
with
36 additions
and
4 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 |
---|---|---|
@@ -1,11 +1,25 @@ | ||
package core.basesyntax; | ||
|
||
public class Ball { | ||
private String color; | ||
private int number; | ||
final String color; | ||
final int number; | ||
|
||
public Ball(String color, int number) { | ||
this.color = color; | ||
this.number = number; | ||
} | ||
|
||
public String getColor() { | ||
return color; | ||
} | ||
|
||
public int getNumber() { | ||
return number; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return super.toString(); | ||
return "Information about ball:\n color: " + getColor().toLowerCase() + " number: " + getNumber(); | ||
} | ||
|
||
} |
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,11 @@ | ||
package core.basesyntax; | ||
|
||
import java.util.Random; | ||
|
||
public class Lottery { | ||
public Ball getRandomBall() { | ||
String newBallColor = ColorSupplier.getRandomColor(); | ||
int newBallNumber = new Random().nextInt(100); | ||
return new Ball(newBallColor, newBallNumber); | ||
} | ||
} |