Created
October 26, 2020 18:56
-
-
Save lucoram/e35da57469b92e4e99e0d6dcdcd67248 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
public class Driver { | |
public static void main(String[] args) throws InterruptedException { | |
Random r = new Random(); | |
Programme p = new Programme(); | |
long startTime = System.currentTimeMillis(); | |
while (true) { | |
long currentTime = System.currentTimeMillis(); | |
int newValue = r.nextInt(100); | |
p.updateValue(newValue); | |
System.out.println("------------------------"); | |
System.out.println("Time : " + ((currentTime - startTime) / 1000) + "s"); | |
System.out.println("new Value : " + newValue); | |
System.out.println("prog Value : " + p.getMaxValue()); | |
Thread.sleep(1000); | |
} | |
} | |
} | |
class Programme { | |
private int maxValue; | |
public void updateValue(int newValue) { | |
maxValue = Math.max(newValue, maxValue); | |
} | |
public int getMaxValue() { | |
return maxValue; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment