Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package AirportPkg;
- import java.util.Date;
- import java.util.Random;
- import AirportPkg.Airplane.AirplaneState;
- public class Utils {
- private static Random rnd = new Random();
- // time between two airplanes calls
- private static int minCallTime = 50;
- private static int maxCallTime = 150;
- // time for airplane to land
- private static int minLandTime = 30;
- private static int maxLandTime = 230;
- // time for airplane to take off
- private static int minTakeOffTime = 80;
- private static int maxTakeOffTime = 260;
- // array of final states for an airplane, defined in Airplane.java
- private static AirplaneState[] stateArray = AirplaneState.values();
- // print a log message
- public static void printLog(String tag, String message) {
- System.out.printf("%d : %-6s : %s\n", (new Date()).getTime(), tag,
- message);
- }
- // get random time to the next airplane call
- public static int getNextCallTime() {
- return minCallTime + rnd.nextInt(maxCallTime - minCallTime + 1);
- }
- // get random time for airplane to land
- public static int getLandingTime() {
- return minLandTime + rnd.nextInt(maxLandTime - minLandTime + 1);
- }
- // get random time for airplane to take off
- public static int getTakingOffTime() {
- return minTakeOffTime
- + rnd.nextInt(maxTakeOffTime - minTakeOffTime + 1);
- }
- // get random state for an airplane
- public static AirplaneState getRandomState() {
- return stateArray[rnd.nextInt(stateArray.length)];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement