0

Can some one help me solve this random generator with peak values in between

package com.suneel.tools; import java.util.Random; import java.util.Timer; import java.util.TimerTask; public class Submitresp extends Main { public static Timer timert = new Timer(); public static int timervalue = 0; public static int prevValue; public static void main(String[] args) { timert.scheduleAtFixedRate(timervalueIncrementer, 2, 2); while (prevValue < 4) { System.out.println(getSubmitresp(5, 9, 300, 700)); } } public static TimerTask timervalueIncrementer = new TimerTask() { @Override public void run() { timervalue = timervalue + 1; } }; // discrete value provider /* * min : low response min limit * max : low response max limit * lmax : max response min limit * lmin : max response max limit */ public static long getSubmitresp(int min, int max, int lmin, int lmax) { if (timervalue != prevValue) { prevValue++; return getRandomMaxResp(lmin, lmax); } else { return getRandomLowResp(min, max); } } // random value generators private static int getRandomLowResp(int min, int max) { if (min >= max) { throw new IllegalArgumentException("max must be greater than min"); } Random r = new Random(); return r.nextInt((max - min) + 1) + min; } private static int getRandomMaxResp(int min, int max) { if (min >= max) { throw new IllegalArgumentException("max must be greater than min"); } Random r = new Random(); return r.nextInt((max - min) + 1) + min; } }

20th Oct 2018, 1:01 PM
seelam suneel
seelam suneel - avatar
3 odpowiedzi
0
Not complete code
20th Oct 2018, 1:47 PM
Daniel (kabura)
Daniel (kabura) - avatar
0
completed the task. now can see the random low numbers and peak values will be triggered when timertask calls.
20th Oct 2018, 1:56 PM
seelam suneel
seelam suneel - avatar
0
Thank you Daniel, can review this once and post if you can improve it better
20th Oct 2018, 1:57 PM
seelam suneel
seelam suneel - avatar