diff --git a/docs/PM2_ClassDiagram.drawio b/docs/PM2_ClassDiagram.drawio
index 3c57fb8..bab77fe 100644
--- a/docs/PM2_ClassDiagram.drawio
+++ b/docs/PM2_ClassDiagram.drawio
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/src/Text.java b/src/Text.java
index 21a3df7..dc0bbdb 100644
--- a/src/Text.java
+++ b/src/Text.java
@@ -2,8 +2,17 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
+/**
+ * New class Text
+ * This class saves and edits the text.
+ * Authors: Roman Schenk, Andrin Fassbind
+ * Date: 12.11.2021
+ */
public class Text {
+ /**
+ * The DataFields text and dummyText save the objects that are being used in this class.
+ */
private final ArrayList text = new ArrayList<>();
private static final String dummyText = "The standard Lorem Ipsum passage, used since the 1500s \"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.\" Section 1.10.32 of \"de Finibus Bonorum et Malorum\", written by Cicero in 45 BC \"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?";
@@ -89,11 +98,11 @@ public class Text {
}
/**
- * Method to replace characters in the last paragraph
+ * Method to replace characters in the last paragraph.
*
* @param oldChar the old character.
* @param newChar the new character.
- * @return returns true if the paragraph is changed successfully
+ * @return returns true if the paragraph is changed successfully.
*/
public boolean replace(String oldChar, String newChar) {
if(paragraphExists(text.size())) {
@@ -104,11 +113,11 @@ public class Text {
}
/**
- * This method deletes a specific paragraph. As a parameter it uses a int.
+ * This method deletes a specific paragraph. As a parameter it uses an int.
* If the parameter is valid it deletes the specific pararaph otherwise it will return false.
*
- * @param paragraphNumber the Paragraph which should be deleted.
- * @return False: If the int is not a valid paragraph. || True: If the int is a valid paragraph number
+ * @param paragraphNumber the paragraph which should be deleted.
+ * @return False: If the int is not a valid paragraph. || True: If the int is a valid paragraph number.
*/
public boolean del(int paragraphNumber) {
if (paragraphExists(paragraphNumber)) {
diff --git a/src/TextEditor.java b/src/TextEditor.java
index 9839adb..e296352 100644
--- a/src/TextEditor.java
+++ b/src/TextEditor.java
@@ -1,12 +1,18 @@
+/**
+ * New class TextEditor
+ * This class contains the main method.
+ * Author: Michael Ziegler
+ * Date: 12.11.2021
+ */
public class TextEditor {
/**
* Main Method that is connected to the TextLogik class.
+ *
* @param args there are no arguments needed.
*/
-
public static void main(String[] args) {
- TextLogik t = new TextLogik();
+ TextLogic t = new TextLogic();
}
diff --git a/src/TextInput.java b/src/TextInput.java
index f7f68d9..2d63271 100644
--- a/src/TextInput.java
+++ b/src/TextInput.java
@@ -1,13 +1,32 @@
import java.util.Scanner;
+/**
+ * New class TextInput
+ * This class checks for new command inputs and gets the text input.
+ * Author: Michael Ziegler
+ * Date: 12.11.2021
+ */
public class TextInput {
+ /**
+ * DataField Scanner saves the object that is being used in this class.
+ */
private static final Scanner sc = new Scanner(System.in);
+ /**
+ * Method to check for new input.
+ *
+ * @return the StringArray with the commands.
+ */
public static String[] checkForInput() {
return sc.nextLine().toUpperCase().split(" ");
}
+ /**
+ * Gets the text that has been written.
+ *
+ * @return the next line.
+ */
public static String getTextInput() {
return sc.nextLine();
}
diff --git a/src/TextLogik.java b/src/TextLogic.java
similarity index 91%
rename from src/TextLogik.java
rename to src/TextLogic.java
index 376ed96..9205b27 100644
--- a/src/TextLogik.java
+++ b/src/TextLogic.java
@@ -1,13 +1,23 @@
-public class TextLogik {
+/**
+ * New class TextLogic
+ * This class defines the commands and initiates the methods of the Text class and TextOutput class.
+ * Authors: Michael Ziegler, Stefan Amador
+ * Date: 12.11.2021
+ */
+public class TextLogic {
+
+ /**
+ * The DataFields text and textOutput save the objects that are being used later in this class.
+ */
private final Text text;
private final TextOutput textOutput;
/**
- * Initiates a new instance of the class TextLogik.
+ * Initiates a new instance of the class TextLogic.
* Contains command instructions for the class Text.
* Defined the different cases and appointed to specific commands.
*/
- public TextLogik() {
+ public TextLogic() {
text = new Text();
textOutput = new TextOutput();
String[] command;
diff --git a/src/TextOutput.java b/src/TextOutput.java
index 0083d52..fdfaccb 100644
--- a/src/TextOutput.java
+++ b/src/TextOutput.java
@@ -1,14 +1,17 @@
import java.util.ArrayList;
/**
- *
+ * New class TextOutput
+ * This class puts out the finished text and formats the text if wanted.
+ * Author: Leonardo Brandenberger
+ * Date: 12.11.2021
*/
public class TextOutput {
private boolean formatRaw;
private int columnWidth = 20;
/**
- * Method which checks in which way the paragraphs should be displayed. And then calls the corresponding
+ * Method that checks in which way the paragraphs should be displayed and then calls the corresponding
* method to output the text as desired.
*
* @param text the ArrayList which is then formatted into the desired output.
@@ -33,7 +36,6 @@ public class TextOutput {
for (int counter = 0; counter < text.size(); counter++) {
System.out.println("<" + (counter + 1) + ">: <" + text.get(counter) + ">");
}
-
}
/**
@@ -50,22 +52,16 @@ public class TextOutput {
int currentWordNumber = 0;
for(String word : words) {
currentWordNumber++;
- if (word.length()<= columnWidth - currentLength) {
- System.out.print(word);
+ if (word.length()>= columnWidth - currentLength && currentWordNumber != 1) {
+ System.out.println();
+ currentLength = 0;
}
- else {
- if(currentWordNumber != 1) {
- System.out.println();
- currentLength = 0;
- }
- System.out.print(word);
+ System.out.print(word);
- }
if(!(currentWordNumber == lastWordNumber)) {
System.out.print(" ");
currentLength = currentLength + word.length() + 1;
- }
- else {
+ } else {
System.out.println();
}
}
@@ -83,17 +79,16 @@ public class TextOutput {
}
/**
- * Method to set the formatRaw to false and also set the length of the desired paragraph length in order to limit
+ * Method to set the formatRaw to false and also to set the length of the desired paragraph length in order to limit
* the paragraph length when printing the text.
*
* @param length the paragraph length when printing the text.
- * @return returns true if successful and false if and invalid length has been submitted.
*/
public void formatFix(int length) {
if(length > 0) {
formatRaw = false;
columnWidth = length;
- userInfoOutput("Command was successfull");
+ userInfoOutput("Command was successful");
}
else {
System.err.println("Minimum length has to be greater than 0");