change in Method add in Text.java
This commit is contained in:
parent
55fd84380b
commit
65af721a7a
|
@ -25,6 +25,9 @@ public class Text {
|
||||||
* @return returns true if the given paragraph exists and is added successfully
|
* @return returns true if the given paragraph exists and is added successfully
|
||||||
*/
|
*/
|
||||||
public boolean add(int paragraphNumber, String text) {
|
public boolean add(int paragraphNumber, String text) {
|
||||||
|
if(text.length() < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (paragraphExists(paragraphNumber)) {
|
if (paragraphExists(paragraphNumber)) {
|
||||||
this.text.add((paragraphNumber - 1), text);
|
this.text.add((paragraphNumber - 1), text);
|
||||||
return true;
|
return true;
|
||||||
|
@ -39,6 +42,9 @@ public class Text {
|
||||||
* @return returns true if the paragraph is added successfully
|
* @return returns true if the paragraph is added successfully
|
||||||
*/
|
*/
|
||||||
public boolean add(String text) {
|
public boolean add(String text) {
|
||||||
|
if(text.length() < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
this.text.add(text.replaceAll("[^A-Za-z0-9 .,:?!\"'-]",""));
|
this.text.add(text.replaceAll("[^A-Za-z0-9 .,:?!\"'-]",""));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue