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

fillresponses2

By: ace on Jan 23rd, 2010  |  syntax: None  |  size: 1.16 KB  |  hits: 14  |  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.  
  5. /**
  6.  * The responder class represents a response generator object.
  7.  * It is used to generate an automatic response.
  8.  *
  9.  * @author     Michael Kolling and David J. Barnes
  10.  * @version    0.1
  11.  */
  12. public class Responder
  13. {
  14.     /**
  15.      * Construct a Responder - nothing to do
  16.      */
  17.     public Responder responder;
  18.     Random randomGenerator;
  19.     private ArrayList<String> responses;
  20.     private fillResponses();
  21.     {
  22.     }
  23.  
  24.     /**
  25.      * Generate a response.
  26.      * @return   A string that should be displayed as the response
  27.      */
  28.     public String generateResponse()
  29.     {
  30.         return "That sounds interesting. Tell me more...";
  31.     }
  32.    
  33.      public String GetResponse()
  34.     {
  35.         int index = randomGenerator.nextInt(3);
  36.         {
  37.            return responses.get(index);
  38.          }
  39.         }
  40.    
  41.     public void createResponses()
  42.     {
  43.         responses.add(response);
  44.     }
  45.    
  46.     private void fillResponses()
  47.     {
  48.         responses.createResponses ("yes");
  49.         responses.createResponses ("no");
  50.         responses.createResponses ("maybe");
  51.     }
  52.    
  53. }