-
Notifications
You must be signed in to change notification settings - Fork 3k
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
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
Retos/Reto #8 - EL GENERADOR PSEUDOALEATORIO [Media]/java/asjordi.java
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,22 @@ | ||
import java.time.LocalTime; | ||
|
||
public class PseudoRandomGenerator { | ||
|
||
private final LocalTime lt = LocalTime.now(); | ||
private int seed = (int) System.currentTimeMillis(); | ||
|
||
private int generateRandomNumber() { | ||
|
||
seed = (seed * 1103515245 + 12345) & Integer.MAX_VALUE; | ||
|
||
return seed % 101; | ||
|
||
} | ||
|
||
public int generateWithNano() { | ||
|
||
return (lt.getNano() + 1) / 10000000; | ||
|
||
} | ||
|
||
} |