diff --git a/src/Text.java b/src/Text.java index 5d47ca8..b17364f 100644 --- a/src/Text.java +++ b/src/Text.java @@ -5,40 +5,75 @@ public class Text { private ArrayList text = new ArrayList<>(); private String dummyText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; - public boolean add(int n, String text) { - if(n < this.text.size()) { - this.text.add(n, text); + /** + * Method to add a paragraph at a specific position. + * @param paragraphNumber number of paragraph where the new text should be added + * @param text the Text which should be added. + * @return returns true if the given paragraph exists and is added successfully + */ + public boolean add(int paragraphNumber, String text) { + if(paragraphNumber < this.text.size()) { + this.text.add(paragraphNumber, text); return true; } return false; } + + /** + * Method to add a paragraph at the end of the existing text. + * @param text the Text which should be added. + * @return returns true if the paragraph is added successfully + */ public boolean add(String text) { this.text.add(text); return true; } - public boolean dummy(int n) { - return add(n, dummyText); + /** + * Method to add a dummy text paragraph at a specific position. + * @param paragraphNumber number of paragraph where the dummy text should be added + * @return returns true if the given paragraph exists and is added successfully + */ + public boolean dummy(int paragraphNumber) { + return add(paragraphNumber, dummyText); } + + /** + * Method to add a dummy text paragraph at the end of the existing text. + * @return returns true if the paragraph is added successfully + */ public boolean dummy() { return add(dummyText); } - public boolean replace(int n, String oldString, String replaceString) { - if(n < this.text.size()) { + /** + * + * @param paragraphNumber + * @param oldString + * @param replaceString + * @return + */ + public boolean replace(int paragraphNumber, String oldString, String replaceString) { + if(paragraphNumber < this.text.size()) { return true; } return false; } - public boolean replace() { + public boolean replace(String oldString, String replaceString) { return true; } - public void del(int n) { + public boolean del(int paragraphNumber) { + if(paragraphNumber < this.text.size()) { + //paragraph hier löschen. + return true; + } + return false; } - public void del() { - + public boolean del() { + //letzter paragraph hier löschen. + return true; } diff --git a/src/TextEditor.java b/src/TextEditor.java index 45cd654..cf36f23 100644 --- a/src/TextEditor.java +++ b/src/TextEditor.java @@ -2,5 +2,7 @@ public class TextEditor { public static void main(String[] args) { + + } }