package com.palacesun.engine.maskingtool;

import java.util.Random;

public class RandomnumTool {
   int count = 0;
   int start = 0;
   int end = 0;
   boolean[] bool;

   public RandomnumTool() {
   }

   public RandomnumTool(int start, int end) {
      this.start = start;
      this.end = end;
      this.bool = new boolean[end];
   }

   public int randomnum() {
      if (this.end - this.start == this.count) {
         this.bool = new boolean[this.end];
         this.count = 0;
      }

      Random rand = new Random();
      int randInt = 0;

      do {
         randInt = rand.nextInt(this.end) % (this.end - this.start + 1) + this.start;
      } while(this.bool[randInt]);

      this.bool[randInt] = true;
      ++this.count;
      return randInt;
   }

   public static void main(String[] args) {
      RandomnumTool rand = new RandomnumTool(0, 10);
      rand.randomnum();
      rand.randomnum();
      rand.randomnum();
      rand.randomnum();
      rand.randomnum();
      rand.randomnum();
      rand.randomnum();
      rand.randomnum();
      rand.randomnum();
      rand.randomnum();
      rand.randomnum();
      rand.randomnum();
   }
}
