Java Random String getRandomFromTier(int tier, String lvlRange)

Here you can find the source of getRandomFromTier(int tier, String lvlRange)

Description

get Random From Tier

License

Open Source License

Declaration

public static int getRandomFromTier(int tier, String lvlRange) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.*;

public class Main {
    public static int getRandomFromTier(int tier, String lvlRange) {
        Random r = new Random();
        int Low = 1;
        int High = 10;
        int R;//from w  w w. java 2s . c o  m
        //TODO: Remove the +2 from every level when we implement high/low properly
        switch (tier) {
        case 1:
            Low = 1;
            if (lvlRange.equalsIgnoreCase("high"))
                Low = 5;
            High = 10;
            if (lvlRange.equalsIgnoreCase("low"))
                High = 5;
            R = r.nextInt(High - Low) + Low + 2;
            return R;
        case 2:
            Low = 10;
            if (lvlRange.equalsIgnoreCase("high"))
                Low = 15;
            High = 20;
            if (lvlRange.equalsIgnoreCase("low"))
                High = 15;
            R = r.nextInt(High - Low) + Low + 2;
            return R;
        case 3:
            Low = 20;
            if (lvlRange.equalsIgnoreCase("high"))
                Low = 25;
            High = 30;
            if (lvlRange.equalsIgnoreCase("low"))
                High = 25;
            R = r.nextInt(High - Low) + Low + 2;
            return R;
        case 4:
            Low = 30;
            if (lvlRange.equalsIgnoreCase("high"))
                Low = 35;
            High = 40;
            if (lvlRange.equalsIgnoreCase("low"))
                High = 35;
            R = r.nextInt(High - Low) + Low + 2;
            return R;
        case 5:
            Low = 40;
            if (lvlRange.equalsIgnoreCase("high"))
                Low = 45;
            High = 100;
            if (lvlRange.equalsIgnoreCase("low"))
                High = 95;
            R = r.nextInt(High - Low) + Low + 2;
            return R;
        }
        return 1;
    }
}

Related

  1. genRandomString(int count)
  2. getDefaultRandomName(String namePrefix)
  3. getRandomAString(int min, int max)
  4. getRandomColors(final int size, final List colors)
  5. getRandomElementOrCompound(String equation)
  6. getRandomNumberString(int length)
  7. getRandomNumberString(int maxValue, int strLen)
  8. getRandomNumberStringBase36(int strLen)
  9. getRandomStr()