mardi 22 septembre 2015

Random number gap

I am trying to complete a program that simply goes through a range of numbers randomly. In the program, I am to construct an array of the ranged numbers and in each index, store the time of when that number appeared,(example: 1st time or 5th time randomly). For the tricky part, if a number appears 2 or 3 times, I want to be able to take the time of the number currently and subtract the time it came up previously to give me the gap of when it appeared.( example: if the number 4 appeared the 1st time and 4th time, then 4-1=3 and 3 is the gap). After I find the gap, I want to store it in an arraylist that stores the gaps.

The first class is the second class tester to run the GapTest. I am not looking for anyone to complete it and give me code, I am simply asking for direction and advice to where I should start since I am just a beginner at this and want to continue learning.

Thank You!

 import java.io.*;
 import java.util.*;

   public class RandomGapMain {

      public static void main(String[] arg)throws IOException{

  Integer range = 20;
  RandomGapTest Test = new RandomGapTest(range); //initialize and object with the range.

  Test.RunTest(5000);  //runs the test 5000 times.
  ArrayList<Integer> Gap = Test.GetGapData();
  for(int i=0; i < Gap.size(); i++){
     System.out.println(i+"\t"+Gap.get(i));
      }

    }

  }




    public class RandomGapTest {

    private Integer range;  //numbers used in random generator

    private Integer[] Uniform;    

    public 

    ArrayList<Integer> Gap = new ArrayList<Integer>();      


   /*
   * RandomGapTest Constructor
   */   
    public RandomGapTest(Integer range){
  this.range = range;
  Gap = new ArrayList<Integer>();



   }

    public void RunTest(Integer Num){


    }

    public ArrayList<Integer> GetGapData(){
    return this.Gap;  
    }





    }




Aucun commentaire:

Enregistrer un commentaire