List of usage examples for java.lang Math random
public static double random()
From source file:edu.ttu.spm.cheapride.model.item.Vehicle.java
private static Vehicle createRandomVehicle() { String color = "Green"; String make = "Toyota"; String licensePlate = String.valueOf(1000 + (int) (10000 * Math.random())); String licenseState = "Txt"; String year = String.valueOf(2000 + (int) (20 * Math.random())); String imageUrl = "https://public-api.lyft.com/static/images/prius_blue.png"; return new Vehicle(color, make, licensePlate, year, licenseState, "", imageUrl); }
From source file:com.busimu.core.license.LicenseGenerator.java
private String generateLicenseCode() { String licenseCode = ""; for (int i = 0; i < 16; i++) { int index = (int) (Math.random() * 62); if (index < 10) { licenseCode += (char) (index + '0'); } else if (index < 36) { licenseCode += (char) (index + 'A' - 10); } else if (index < 62) { licenseCode += (char) (index + 'a' - 36); } else {//w w w .ja v a 2 s.c o m throw new RuntimeException("Wrong Index " + index); } if (i % 4 == 3 && i != 15) { licenseCode += '-'; } } return licenseCode; }
From source file:mini_mirc_client.Mini_mirc_client.java
public static void generateUname() { String commonUsername[] = { "Earthshaker", "Sven", "Tiny", "Kunkka", "Beastmaster", "DragonKnight", "Axe", "Pudge", "SandKing", "Slardar", "Tidehunter", "WraithKing", "Bloodseeker", "Windranger", "StormSpirit", "Lina", "ShadowFiend", "AntiMage", "PhantomAssassin" }; String uname;/*from w ww. j av a 2 s . co m*/ int randIndex = (int) Math.round(Math.random() * (commonUsername.length - 1)); int randEnd = (int) (Math.random() * 999); uname = commonUsername[randIndex] + randEnd; System.out.println("# Generated new username: " + uname); username = uname; }
From source file:Main.java
private ObservableList<XYChart.Series<String, Double>> getChartData() { double aValue = 17.56; double cValue = 17.06; ObservableList<XYChart.Series<String, Double>> answer = FXCollections.observableArrayList(); Series<String, Double> aSeries = new Series<String, Double>(); Series<String, Double> cSeries = new Series<String, Double>(); aSeries.setName("a"); cSeries.setName("C"); for (int i = 2011; i < 2021; i++) { aSeries.getData().add(new XYChart.Data(Integer.toString(i), aValue)); aValue = aValue + Math.random() - .5; cSeries.getData().add(new XYChart.Data(Integer.toString(i), cValue)); cValue = cValue + Math.random() - .5; }// w w w . java 2 s .c o m answer.addAll(aSeries, cSeries); return answer; }
From source file:Main.java
private ObservableList<XYChart.Series<String, Double>> getChartData() { double aValue = 1.56; double cValue = 1.06; ObservableList<XYChart.Series<String, Double>> answer = FXCollections.observableArrayList(); Series<String, Double> aSeries = new Series<String, Double>(); Series<String, Double> cSeries = new Series<String, Double>(); aSeries.setName("a"); cSeries.setName("C"); for (int i = 2011; i < 2021; i++) { aSeries.getData().add(new XYChart.Data(Integer.toString(i), aValue)); aValue = aValue + Math.random() - .5; cSeries.getData().add(new XYChart.Data(Integer.toString(i), cValue)); cValue = cValue + Math.random() - .5; }/*w w w . j av a 2 s. c o m*/ answer.addAll(aSeries, cSeries); return answer; }
From source file:org.openmrs.contrib.metadatarepository.webapp.controller.BaseControllerTestCase.java
@Before public void onSetUp() { smtpPort = smtpPort + (int) (Math.random() * 100); // change the port on the mailSender so it doesn't conflict with an // existing SMTP server on localhost JavaMailSenderImpl mailSender = (JavaMailSenderImpl) applicationContext.getBean("mailSender"); mailSender.setPort(getSmtpPort());//from www . java 2 s.c om mailSender.setHost("localhost"); }
From source file:com.dbschools.music.ClientSession.java
public ClientSession(User user, String databaseName) { this.user = user; this.databaseName = databaseName; sessionId = (int) (Math.random() * Integer.MAX_VALUE); }
From source file:com.acc.fulfilmentprocess.actions.consignment.SubprocessEndAction.java
@Override public void executeAction(final ConsignmentProcessModel process) { LOG.info("Process: " + process.getCode() + " in step " + getClass()); try {//from w w w. j av a 2 s .c o m // simulate different ending times Thread.sleep((long) (Math.random() * 2000)); } catch (final InterruptedException e) { // can't help it } process.setDone(true); save(process); LOG.info("Process: " + process.getCode() + " wrote DONE marker"); getBusinessProcessService().triggerEvent(process.getParentProcess().getCode() + "_" + BncFulfilmentProcessConstants.CONSIGNMENT_SUBPROCESS_END_EVENT_NAME); LOG.info("Process: " + process.getCode() + " fired event " + BncFulfilmentProcessConstants.CONSIGNMENT_SUBPROCESS_END_EVENT_NAME); }
From source file:com.mitre.fulfilmentprocess.actions.consignment.SubprocessEndAction.java
@Override public void executeAction(final ConsignmentProcessModel process) { LOG.info("Process: " + process.getCode() + " in step " + getClass()); try {/* ww w .j a va2 s . c o m*/ // simulate different ending times Thread.sleep((long) (Math.random() * 2000)); } catch (final InterruptedException e) { // can't help it } process.setDone(true); save(process); LOG.info("Process: " + process.getCode() + " wrote DONE marker"); getBusinessProcessService().triggerEvent(process.getParentProcess().getCode() + "_" + MitreFulfilmentProcessConstants.CONSIGNMENT_SUBPROCESS_END_EVENT_NAME); LOG.info("Process: " + process.getCode() + " fired event " + MitreFulfilmentProcessConstants.CONSIGNMENT_SUBPROCESS_END_EVENT_NAME); }
From source file:org.chos.transaction.passport.controller.CaptchaController.java
private Color generateColor() { int r = (int) (Math.random() * 180); int g = (int) (Math.random() * 180); int b = (int) (Math.random() * 180); return new Color(r, g, b); }