From 2a89ffe7cd97da2d0e45c6a6f19883923bae8c44 Mon Sep 17 00:00:00 2001 From: Jordi Ayala Date: Wed, 12 Jul 2023 09:53:09 -0600 Subject: [PATCH] Reto #8 - Java --- .../java/asjordi.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Retos/Reto #8 - EL GENERADOR PSEUDOALEATORIO [Media]/java/asjordi.java diff --git a/Retos/Reto #8 - EL GENERADOR PSEUDOALEATORIO [Media]/java/asjordi.java b/Retos/Reto #8 - EL GENERADOR PSEUDOALEATORIO [Media]/java/asjordi.java new file mode 100644 index 0000000000..275db69fd8 --- /dev/null +++ b/Retos/Reto #8 - EL GENERADOR PSEUDOALEATORIO [Media]/java/asjordi.java @@ -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; + + } + +}