[Sync Iteration] java/captains-log/1

This commit is contained in:
exercism-solutions-syncer[bot] 2026-04-16 17:56:37 +00:00 committed by GitHub
parent f80fbca12e
commit e9ab9fc04f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -0,0 +1,30 @@
import java.util.Random;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
class CaptainsLog {
private static final char[] PLANET_CLASSES = new char[]{'D', 'H', 'J', 'K', 'L', 'M', 'N', 'R', 'T', 'Y'};
private Random random;
CaptainsLog(Random random) {
this.random = random;
}
char randomPlanetClass() {
List<Character> buchstaben = List.of('D', 'H', 'J', 'K', 'L', 'M', 'N', 'R', 'T', 'Y');
int index = random.nextInt(buchstaben.size());
return buchstaben.get(index);
}
String randomShipRegistryNumber() {
int zahl = random.nextInt(10000 - 1000) + 1000;
return "NCC-" + zahl;
}
double randomStardate() {
return 41000 +random.nextDouble() * (42000 - 41000);
}
}