List of usage examples for java.lang Math random
public static double random()
From source file:org.jongo.mocks.UserMock.java
public static String getRandomBirthDate() { String year = String.valueOf(1950 + (int) (Math.random() * ((2010 - 1950) + 1))); String month = String.valueOf(1 + (int) (Math.random() * ((12 - 1) + 1))); String day = String.valueOf(1 + (int) (Math.random() * ((30 - 1) + 1))); if (month.length() == 1) month = "0" + month; if (day.length() == 1) day = "0" + day; return year + "-" + month + "-" + day; }
From source file:org.jfree.chart.demo.CompassFormatDemo1.java
private static XYDataset createForceDataset(int i) { TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); TimeSeries timeseries = new TimeSeries("Wind Force"); Object obj = new Minute(); double d = 3D; for (int j = 0; j < i; j++) { timeseries.add(((RegularTimePeriod) (obj)), d); obj = ((RegularTimePeriod) (obj)).next(); d = Math.max(0.5D, d + (Math.random() - 0.5D) * 0.5D); }//from w w w .j a v a 2s . c o m timeseriescollection.addSeries(timeseries); return timeseriescollection; }
From source file:blue.lapis.pore.converter.type.world.effect.EffectConverter.java
public static SoundType toSound(Effect effect, int data) { if (effect.getType() == Effect.Type.SOUND) { switch (effect) { case CLICK2: return SoundTypes.WOOD_CLICK; case CLICK1: return SoundTypes.CLICK; case BOW_FIRE: return SoundTypes.SHOOT_ARROW; case DOOR_TOGGLE: return Math.random() >= 0.5 ? SoundTypes.DOOR_OPEN : SoundTypes.DOOR_CLOSE; case EXTINGUISH: return SoundTypes.FIZZ; //TODO: verify this is the correct sound case RECORD_PLAY: throw new NotImplementedException("TODO"); case GHAST_SHRIEK: return SoundTypes.GHAST_SCREAM; case GHAST_SHOOT: return SoundTypes.GHAST_FIREBALL; case BLAZE_SHOOT: return SoundTypes.BLAZE_BREATH; case ZOMBIE_CHEW_WOODEN_DOOR: return SoundTypes.ZOMBIE_WOOD; case ZOMBIE_CHEW_IRON_DOOR: return SoundTypes.ZOMBIE_METAL; case ZOMBIE_DESTROY_DOOR: return SoundTypes.ZOMBIE_WOODBREAK; case STEP_SOUND: throw new NotImplementedException("TODO"); //TODO: determine generic type of block default:/*w w w .j ava 2s .co m*/ return null; } } return null; }
From source file:net.eusashead.hateoas.response.impl.CustomerRepository.java
public Page<Customer> listCustomers(Pageable page) { List<Customer> orders = new ArrayList<Customer>(); for (int i = 0; i < page.getPageSize(); i++) { orders.add(new Customer(i, BigDecimal.valueOf(Math.random() * 100), new Date(Math.round(123456789l * Math.random())))); }/*from w ww .j a v a 2s .c o m*/ return new PageImpl<Customer>(orders, page, 95); }
From source file:net.floodlightcontroller.loadbalancer.LBMember.java
public LBMember() { id = String.valueOf((int) (Math.random() * 10000)); address = 0;/*from w w w . ja va 2 s . com*/ macString = null; port = 0; connectionLimit = 0; adminState = 0; status = 0; poolId = null; vipId = null; }
From source file:MainClass.java
public void updateStocks() { for (int i = 0; i < data.length; i++) { data[i] = Math.random(); } }
From source file:com.wootric.androidsdk.utils.SHAUtil.java
public static String randomString() { String text = ""; int i = 0;/*from w w w .j a v a2 s.c o m*/ while (i < 16) { text += POSSIBLE.charAt((int) (Math.random() * POSSIBLE.length())); i++; } return text; }
From source file:com.apress.prospringintegration.corespring.aop.PurchaseOrderDiscountProcessorImpl.java
public Receipt processDiscountOrder(PurchaseOrder order, DiscountStrategy discountStrategy) throws Exception { order.setProcessedTime(Calendar.getInstance().getTime()); float cost = order.getItemCost(); float discountAmt = cost * discountStrategy.discountRate; order.setDiscountAmount(discountAmt); Receipt receipt = new Receipt(); receipt.setPurchaseAmt(cost);//www. ja va 2 s . c o m receipt.setDiscountedAmount(discountAmt); receipt.setAuthcode(Math.round(Math.random() * 2000000)); return receipt; }
From source file:fr.pasteque.client.models.Payment.java
public Payment(PaymentMode mode, double amount, double given) { this.mode = mode; this.amount = amount; this.given = given; this.innerId = (int) (Math.random() * Integer.MAX_VALUE); }
From source file:codeswarm.processing.ColorTest.java
public int assign() { return PApplet.lerpColor(c1, c2, (float) Math.random(), PConstants.RGB); }