//package WordSeparator;
/*
public class WordExtractor {

   // Data field
   String sentence;

   public WordExtractor(String sent) {
      sentence = sent;
   }

   // Precondition - sentence has at least two words separated by a blank
   // Postcondition - the first word of sentence is removed and
   //                   is returned as the method result
   public String getFirstWord() {
     // Find first blank.
     int posBlank = sentence.indexOf(" ");

     // Return first word .
     return sentence.substring(0, posBlank);
   }

   public String getRest() {
     // Find first blank.
     int posBlank = sentence.indexOf(" ");

     // Return rest of sentence.
     return sentence.substring(posBlank + 1);
   }

   // Returns the state of this object.
   public String toString() {
     return sentence;
   }
}
*/
public class WordExtractor {

   // Data field
   String sentence;

   // Constructors
   // postcondition - data field sentence references the argument.
   public WordExtractor(String str) {
      sentence = str;
   }

   // precondition - sentence has at least two words separated by a blank
   // postcondition - gets the first word of sentence
   public String getFirst() {
      // Find the position of the first blank in sentence.
      int posBlank = sentence.indexOf(" ");
  
      // Return the characters up to the first blank.
      return sentence.substring(0, posBlank);
   }

   // precondition - sentence has at least two words separated by a blank
   // postcondition - gets the part of sentence after the first blank
   public String getRest() {
      // Find the position of the first blank in sentence.
      int posBlank = sentence.indexOf(" ");
  
      // Return the characters after the first blank.
      return sentence.substring(posBlank + 1);
   }

   // postcondition - returns the state of this object.
   public String toString() {
      return sentence;
   }
}

