Code example for Random

Methods: nextBytesnextFloat

0
	public ArrayList<Note> getNotes() {
		return notes; 
	} 
	 
	public void addNote() { 
		Random random = new Random();
		 
		byte[] b = new byte[1];
		random.nextBytes(b);
		int randomIndex = ((int)b[0]) % 3;
		 
		float greyControl = 0.05f;
		float mixRatio1 = (randomIndex == 0) ? random.nextFloat() * greyControl : random.nextFloat();
		float mixRatio2 = (randomIndex == 1) ? random.nextFloat() * greyControl : random.nextFloat();
		float mixRatio3 = (randomIndex == 2) ? random.nextFloat() * greyControl : random.nextFloat();
		 
		float sum = mixRatio1 + mixRatio2 + mixRatio3;
		 
		mixRatio1 /= sum;
		mixRatio2 /= sum;
Experience pair programming with AI  Get Codota for Java