Advertisement
Guest User

Phrase Class Code

a guest
Jun 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.io.Serializable;
  3. public final class Phrase implements Serializable
  4. {
  5.     public String text;
  6.     public ArrayList<String> responseTo;
  7.     public ArrayList<String> howToProceed;
  8.    
  9.     public Phrase(String text, String[] preceding)
  10.     {
  11.         responseTo = new ArrayList<String>();
  12.         howToProceed = new ArrayList<String>();
  13.         for(int i = 0; i < preceding.length ;i++)
  14.         {
  15.             responseTo.add(preceding[i]);
  16.         }
  17.        
  18.         this.text = text;
  19.     }
  20.    
  21.     public Phrase(String text, String[] preceding, String[] toProceed)
  22.     {
  23.         responseTo = new ArrayList<String>();
  24.         howToProceed = new ArrayList<String>();
  25.         for(int i = 0; i < preceding.length ;i++)
  26.         {
  27.             responseTo.add(preceding[i]);
  28.         }
  29.        
  30.         for(int i = 0; i < toProceed.length ;i++)
  31.         {
  32.             howToProceed.add(toProceed[i]);
  33.         }
  34.        
  35.         this.text = text;
  36.     }
  37.    
  38.     public Phrase(String text)
  39.     {
  40.         responseTo = new ArrayList<String>();
  41.         howToProceed = new ArrayList<String>();
  42.         this.text = text;
  43.     }
  44.    
  45.     public void newPreceding(String phrase)
  46.     {
  47.         responseTo.add(phrase);
  48.     }
  49.    
  50.     public void addResponseTo(String phrase)
  51.     {
  52.         howToProceed.add(phrase);
  53.     }
  54.    
  55.     public String getPhrase()
  56.     {
  57.         return text;
  58.     }
  59.    
  60.     public ArrayList<String> getResponseTo()
  61.     {
  62.         return responseTo;
  63.     }
  64.    
  65.     public ArrayList<String> getHowToProceed()
  66.     {
  67.         return howToProceed;
  68.     }
  69.    
  70.     public String toString()
  71.     {
  72.         return text + " is for: " + responseTo + " how to proceed:" + howToProceed;
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement