Corrections to Javadocs have been made. Changes in method toFormat.

This commit is contained in:
amadoste 2021-11-12 10:21:21 +01:00
parent d3e26c61aa
commit 32cb472310
6 changed files with 67 additions and 28 deletions

File diff suppressed because one or more lines are too long

View File

@ -2,8 +2,17 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; 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 { public class Text {
/**
* The DataFields text and dummyText save the objects that are being used in this class.
*/
private final ArrayList<String> text = new ArrayList<>(); private final ArrayList<String> 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?"; 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 oldChar the old character.
* @param newChar the new 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) { public boolean replace(String oldChar, String newChar) {
if(paragraphExists(text.size())) { 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. * If the parameter is valid it deletes the specific pararaph otherwise it will return false.
* *
* @param paragraphNumber the Paragraph which should be deleted. * @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 * @return False: If the int is not a valid paragraph. || True: If the int is a valid paragraph number.
*/ */
public boolean del(int paragraphNumber) { public boolean del(int paragraphNumber) {
if (paragraphExists(paragraphNumber)) { if (paragraphExists(paragraphNumber)) {

View File

@ -1,12 +1,18 @@
/**
* New class TextEditor
* This class contains the main method.
* Author: Michael Ziegler
* Date: 12.11.2021
*/
public class TextEditor { public class TextEditor {
/** /**
* Main Method that is connected to the TextLogik class. * Main Method that is connected to the TextLogik class.
*
* @param args there are no arguments needed. * @param args there are no arguments needed.
*/ */
public static void main(String[] args) { public static void main(String[] args) {
TextLogik t = new TextLogik(); TextLogic t = new TextLogic();
} }

View File

@ -1,13 +1,32 @@
import java.util.Scanner; 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 { public class TextInput {
/**
* DataField Scanner saves the object that is being used in this class.
*/
private static final Scanner sc = new Scanner(System.in); 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() { public static String[] checkForInput() {
return sc.nextLine().toUpperCase().split(" "); return sc.nextLine().toUpperCase().split(" ");
} }
/**
* Gets the text that has been written.
*
* @return the next line.
*/
public static String getTextInput() { public static String getTextInput() {
return sc.nextLine(); return sc.nextLine();
} }

View File

@ -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 Text text;
private final TextOutput textOutput; 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. * Contains command instructions for the class Text.
* Defined the different cases and appointed to specific commands. * Defined the different cases and appointed to specific commands.
*/ */
public TextLogik() { public TextLogic() {
text = new Text(); text = new Text();
textOutput = new TextOutput(); textOutput = new TextOutput();
String[] command; String[] command;

View File

@ -1,14 +1,17 @@
import java.util.ArrayList; 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 { public class TextOutput {
private boolean formatRaw; private boolean formatRaw;
private int columnWidth = 20; 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. * method to output the text as desired.
* *
* @param text the ArrayList which is then formatted into the desired output. * @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++) { for (int counter = 0; counter < text.size(); counter++) {
System.out.println("<" + (counter + 1) + ">: <" + text.get(counter) + ">"); System.out.println("<" + (counter + 1) + ">: <" + text.get(counter) + ">");
} }
} }
/** /**
@ -50,22 +52,16 @@ public class TextOutput {
int currentWordNumber = 0; int currentWordNumber = 0;
for(String word : words) { for(String word : words) {
currentWordNumber++; currentWordNumber++;
if (word.length()<= columnWidth - currentLength) { if (word.length()>= columnWidth - currentLength && currentWordNumber != 1) {
System.out.print(word);
}
else {
if(currentWordNumber != 1) {
System.out.println(); System.out.println();
currentLength = 0; currentLength = 0;
} }
System.out.print(word); System.out.print(word);
}
if(!(currentWordNumber == lastWordNumber)) { if(!(currentWordNumber == lastWordNumber)) {
System.out.print(" "); System.out.print(" ");
currentLength = currentLength + word.length() + 1; currentLength = currentLength + word.length() + 1;
} } else {
else {
System.out.println(); 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. * the paragraph length when printing the text.
* *
* @param length 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) { public void formatFix(int length) {
if(length > 0) { if(length > 0) {
formatRaw = false; formatRaw = false;
columnWidth = length; columnWidth = length;
userInfoOutput("Command was successfull"); userInfoOutput("Command was successful");
} }
else { else {
System.err.println("Minimum length has to be greater than 0"); System.err.println("Minimum length has to be greater than 0");