Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

getresponse102

By: ace on Jan 23rd, 2010  |  syntax: None  |  size: 2.22 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.util.Random;
  2. import java.util.ArrayList;
  3. /**
  4.  * Write a description of class RandomTester here.
  5.  *
  6.  * @author (your name)
  7.  * @version (a version number or a date)
  8.  */
  9. public class RandomTester
  10. {
  11.     // instance variables - replace the example below with your own
  12.     private int x;
  13.     Random randomGenerator;
  14.     private ArrayList<String> responces;
  15.     /**
  16.      * Constructor for objects of class RandomTester
  17.      */
  18.     public RandomTester()
  19.     {
  20.         // initialise instance variables
  21.         x = 0;
  22.         randomGenerator = new Random();
  23.         responces = new ArrayList<String>();
  24.     }
  25.  
  26.     public void possibleResponses(String responce)
  27.     {
  28.         responces.add(responce);
  29.     }
  30.    
  31.     public String GetResponse()
  32.     {
  33.         int index = randomGenerator.nextInt(3);
  34.         {
  35.             if (index == responces(index))
  36.             {
  37.                 return responces.get(responces);
  38.             }
  39.         }
  40.     }
  41.    
  42.    
  43.     /**
  44.      * An example of a method - replace this comment with your own
  45.      *
  46.      * @param  y   a sample parameter for a method
  47.      * @return     the sum of x and y
  48.      */
  49.     public int sampleMethod(int y)
  50.     {
  51.         // put your code here
  52.         return x + y;
  53.     }
  54.  
  55.     public void printNewRandom()
  56.     {
  57.         int index = randomGenerator.nextInt();
  58.         System.out.println(index);
  59.     }
  60.    
  61.     public void printMultiRandom(int howMany)
  62.     {
  63.     int index = 0;
  64.     {
  65.       while(index < howMany)
  66.         {
  67.  
  68.             System.out.println(randomGenerator.nextInt());
  69.             index++;
  70.        }
  71.     }
  72. }
  73.  
  74.     public int throwDice()
  75.     {
  76.         int index = randomGenerator.nextInt(6);
  77.         {
  78.             return index+1;
  79.         }
  80.     }
  81.    
  82.     /*public String getResponse()
  83.     {
  84.         int index = randomGenerator.nextInt(3);
  85.         {
  86.             if (index == 0)
  87.             {
  88.                 return "yes";
  89.             }
  90.             if(index == 1)
  91.             {
  92.                 return "no";
  93.             }
  94.             if(index == 2)
  95.             {
  96.                 return "maybe";
  97.             }
  98.             else
  99.             {
  100.                 return "null";
  101.             }
  102.     }
  103. }*/
  104.  
  105.  
  106. }