Merge remote-tracking branch 'origin/main'
This commit is contained in:
		
						commit
						42bd8eeadc
					
				| 
						 | 
					@ -25,9 +25,6 @@ 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;
 | 
				
			||||||
| 
						 | 
					@ -42,9 +39,6 @@ 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;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,21 +12,25 @@ public class TextLogik {
 | 
				
			||||||
        textOutput = new TextOutput();
 | 
					        textOutput = new TextOutput();
 | 
				
			||||||
        String[] command;
 | 
					        String[] command;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        textOutput.userInfoOutput("######################");
 | 
					        textOutput.userInfoOutput("#######################");
 | 
				
			||||||
        textOutput.userInfoOutput("#WELCOME TO THE EDITOR#");
 | 
					        textOutput.userInfoOutput("#WELCOME TO THE EDITOR#");
 | 
				
			||||||
        textOutput.userInfoOutput("######################");
 | 
					        textOutput.userInfoOutput("#######################");
 | 
				
			||||||
        do {
 | 
					        do {
 | 
				
			||||||
            textOutput.userInfoOutput("Please enter a Command: ");
 | 
					            textOutput.userInfoOutput("Please enter a Command: ");
 | 
				
			||||||
            command = TextInput.checkForInput();
 | 
					            command = TextInput.checkForInput();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            switch (command[0]) {
 | 
					            switch (command[0]) {
 | 
				
			||||||
                case "ADD":
 | 
					                case "ADD":
 | 
				
			||||||
 | 
					                    String inputText = "";
 | 
				
			||||||
 | 
					                    while(inputText.length() == 0) {
 | 
				
			||||||
                        textOutput.userInfoOutput("Please enter your text: ");
 | 
					                        textOutput.userInfoOutput("Please enter your text: ");
 | 
				
			||||||
 | 
					                        inputText = TextInput.getTextInput();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                    if (command.length == 1) {
 | 
					                    if (command.length == 1) {
 | 
				
			||||||
                        checkIfSuccess(text.add(TextInput.getTextInput()));
 | 
					                        checkIfSuccess(text.add(inputText));
 | 
				
			||||||
                    } else if (isNumeric(command[1])) {
 | 
					                    } else if (isNumeric(command[1])) {
 | 
				
			||||||
                        int line = Integer.parseInt(command[1]);
 | 
					                        int line = Integer.parseInt(command[1]);
 | 
				
			||||||
                        checkIfSuccess(text.add(line, TextInput.getTextInput()));
 | 
					                        checkIfSuccess(text.add(line, inputText));
 | 
				
			||||||
                    } else {
 | 
					                    } else {
 | 
				
			||||||
                        textOutput.errorInvalidCommand();
 | 
					                        textOutput.errorInvalidCommand();
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue