Bearbeiten von „Klassen:Javakurs“
Zur Navigation springen
Zur Suche springen
Warnung: Du bist nicht angemeldet. Deine IP-Adresse wird bei Bearbeitungen öffentlich sichtbar. Melde dich an oder erstelle ein Benutzerkonto, damit Bearbeitungen deinem Benutzernamen zugeordnet werden.
Die Bearbeitung kann rückgängig gemacht werden. Bitte prüfe den Vergleich unten, um sicherzustellen, dass du dies tun möchtest, und veröffentliche dann unten deine Änderungen, um die Bearbeitung rückgängig zu machen.
Aktuelle Version | Dein Text | ||
Zeile 32: | Zeile 32: | ||
this.seed = System.currentTimeMillis(); | this.seed = System.currentTimeMillis(); | ||
} | } | ||
Random(long seed){ | |||
this.seed = seed; | this.seed = seed; | ||
} | } | ||
long next() { | |||
this.seed = Math.abs(this.seed * 0x20041991 + 0x11111989); | this.seed = Math.abs(this.seed * 0x20041991 + 0x11111989); | ||
return this.seed; | return this.seed; | ||
} | } | ||
long next(long min, long max){ | |||
long rc = next(); | long rc = next(); | ||
rc = min == max ? min : min + rc % (max - min); | rc = min == max ? min : min + rc % (max - min); | ||
Zeile 56: | Zeile 56: | ||
} | } | ||
class RealRandom extends Random { | class RealRandom extends Random { | ||
double next(double min, double max){ | |||
double rc = next(0, 1000000000) / 1000000000.0; | double rc = next(0, 1000000000) / 1000000000.0; | ||
rc = min == max ? min : min + rc * (max - min); | rc = min == max ? min : min + rc * (max - min); |