From 65af721a7a53fa6d39d23b94f26cb6dbde69ef8d Mon Sep 17 00:00:00 2001 From: schrom01 Date: Thu, 11 Nov 2021 16:19:30 +0100 Subject: [PATCH] change in Method add in Text.java --- src/Text.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Text.java b/src/Text.java index 902a39a..a4e5f59 100644 --- a/src/Text.java +++ b/src/Text.java @@ -25,6 +25,9 @@ public class Text { * @return returns true if the given paragraph exists and is added successfully */ public boolean add(int paragraphNumber, String text) { + if(text.length() < 1) { + return false; + } if (paragraphExists(paragraphNumber)) { this.text.add((paragraphNumber - 1), text); return true; @@ -39,6 +42,9 @@ public class Text { * @return returns true if the paragraph is added successfully */ public boolean add(String text) { + if(text.length() < 1) { + return false; + } this.text.add(text.replaceAll("[^A-Za-z0-9 .,:?!\"'-]","")); return true; }