protected boolean attemptToAddWord(Word word){
  double additionalLength=word.getWordWidth();
  additionalLength+=!words.isEmpty() ? spaceSize : 0;
  if (currentLineLength + additionalLength <= maxLength || maxLength == -1) {
    words.add(word);
    currentLineLength+=additionalLength;
    return true;
  }
 else {
    return false;
  }
}

protected boolean attemptToAddWord ( Word word ) { double additionalLength = word . getWordWidth ( ) ; additionalLength += ! words . isEmpty ( ) ? spaceSize : 0 ; if ( currentLineLength + additionalLength <= maxLength || maxLength == - 1 ) { words . add ( word ) ; currentLineLength += additionalLength ; return true ; } else { return false ; } }
attempt to add a word to the line . if the line can fit the word in without reaching the maximum line length then the word is added and the line length increased .
