TextLogik sync and Text updated
This commit is contained in:
		
							parent
							
								
									117420c815
								
							
						
					
					
						commit
						d51da11751
					
				| 
						 | 
					@ -39,7 +39,7 @@ 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) {
 | 
				
			||||||
        this.text.add(text);
 | 
					        this.text.add(text.replaceAll("[^A-Za-z0-9 .,:?!\"'-]",""));
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -168,7 +168,7 @@ public class Text {
 | 
				
			||||||
        String firstLetter;
 | 
					        String firstLetter;
 | 
				
			||||||
        String restLetters;
 | 
					        String restLetters;
 | 
				
			||||||
        for (int i = 0; i < text.size(); i++) {
 | 
					        for (int i = 0; i < text.size(); i++) {
 | 
				
			||||||
            String[] words = text.get(i).trim().toLowerCase().split("[ :;.,!?><'/\n]+");
 | 
					            String[] words = text.get(i).trim().toLowerCase().split("[ :;.,!?><+*}{)('/\n]+");
 | 
				
			||||||
            for (String word : words) {
 | 
					            for (String word : words) {
 | 
				
			||||||
                //Words get formatted consistently
 | 
					                //Words get formatted consistently
 | 
				
			||||||
                counter = 1;
 | 
					                counter = 1;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,11 +12,16 @@ public class TextLogik {
 | 
				
			||||||
        textOutput = new TextOutput();
 | 
					        textOutput = new TextOutput();
 | 
				
			||||||
        String[] command;
 | 
					        String[] command;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        textOutput.UserInfoOutput("######################");
 | 
				
			||||||
 | 
					        textOutput.UserInfoOutput("#WELCOME TO THE EDITOR#");
 | 
				
			||||||
 | 
					        textOutput.UserInfoOutput("######################");
 | 
				
			||||||
        do {
 | 
					        do {
 | 
				
			||||||
 | 
					            textOutput.UserInfoOutput("Please enter a Command: ");
 | 
				
			||||||
            command = TextInput.checkForInput();
 | 
					            command = TextInput.checkForInput();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            switch (command[0]) {
 | 
					            switch (command[0]) {
 | 
				
			||||||
                case "ADD":
 | 
					                case "ADD":
 | 
				
			||||||
 | 
					                    textOutput.UserInfoOutput("Please enter your text: ");
 | 
				
			||||||
                    if (command.length == 1) {
 | 
					                    if (command.length == 1) {
 | 
				
			||||||
                        checkIfSuccess(text.add(TextInput.getTextInput()));
 | 
					                        checkIfSuccess(text.add(TextInput.getTextInput()));
 | 
				
			||||||
                    } else if (isNumeric(command[1])) {
 | 
					                    } else if (isNumeric(command[1])) {
 | 
				
			||||||
| 
						 | 
					@ -29,10 +34,10 @@ public class TextLogik {
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                case "DEL":
 | 
					                case "DEL":
 | 
				
			||||||
                    if (command.length == 1) {
 | 
					                    if (command.length == 1) {
 | 
				
			||||||
                        text.del();
 | 
					                        checkIfSuccess(text.del());
 | 
				
			||||||
                    } else if (isNumeric(command[1])) {
 | 
					                    } else if (isNumeric(command[1])) {
 | 
				
			||||||
                        int line = Integer.parseInt(command[1]);
 | 
					                        int line = Integer.parseInt(command[1]);
 | 
				
			||||||
                        text.del(line);
 | 
					                        checkIfSuccess(text.del(line));
 | 
				
			||||||
                    } else {
 | 
					                    } else {
 | 
				
			||||||
                        textOutput.errorInvalidCommand();
 | 
					                        textOutput.errorInvalidCommand();
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
| 
						 | 
					@ -51,9 +56,9 @@ public class TextLogik {
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                case "FORMAT":
 | 
					                case "FORMAT":
 | 
				
			||||||
                    if (command.length > 1 && "RAW".equals(command[1])) {
 | 
					                    if (command.length > 1 && "RAW".equals(command[1])) {
 | 
				
			||||||
                        textOutput.formatRaw();
 | 
					                        checkIfSuccess(textOutput.formatRaw());
 | 
				
			||||||
                    } else if (command.length > 2 && "FIX".equals(command[1]) && isNumeric(command[2])) {
 | 
					                    } else if (command.length > 2 && "FIX".equals(command[1]) && isNumeric(command[2])) {
 | 
				
			||||||
                        textOutput.formatFix(Integer.parseInt(command[2]));
 | 
					                        checkIfSuccess(textOutput.formatFix(Integer.parseInt(command[2])));
 | 
				
			||||||
                    } else {
 | 
					                    } else {
 | 
				
			||||||
                        textOutput.errorInvalidCommand();
 | 
					                        textOutput.errorInvalidCommand();
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
| 
						 | 
					@ -63,11 +68,10 @@ public class TextLogik {
 | 
				
			||||||
                    textOutput.IndexOutput(text.index());
 | 
					                    textOutput.IndexOutput(text.index());
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                case "PRINT":
 | 
					                case "PRINT":
 | 
				
			||||||
 | 
					 | 
				
			||||||
                    textOutput.print(text.getText());
 | 
					                    textOutput.print(text.getText());
 | 
				
			||||||
 | 
					 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                case "REPLACE":
 | 
					                case "REPLACE":
 | 
				
			||||||
 | 
					                    textOutput.UserInfoOutput("Please enter your text to replace: ");
 | 
				
			||||||
                    if (command.length == 1){
 | 
					                    if (command.length == 1){
 | 
				
			||||||
                        checkIfSuccess(text.replace(TextInput.getTextInput(), TextInput.getTextInput()));
 | 
					                        checkIfSuccess(text.replace(TextInput.getTextInput(), TextInput.getTextInput()));
 | 
				
			||||||
                    }else if(isNumeric(command[1])) {
 | 
					                    }else if(isNumeric(command[1])) {
 | 
				
			||||||
| 
						 | 
					@ -98,7 +102,7 @@ public class TextLogik {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void checkIfSuccess(boolean method) {
 | 
					    private void checkIfSuccess(boolean method) {
 | 
				
			||||||
        if(method) {
 | 
					        if(method) {
 | 
				
			||||||
            textOutput.UserInfoOutput("Command was successfully");
 | 
					            textOutput.UserInfoOutput("Command was successfull");
 | 
				
			||||||
        }else {
 | 
					        }else {
 | 
				
			||||||
            textOutput.errorInvalidParagraph();
 | 
					            textOutput.errorInvalidParagraph();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -103,6 +103,7 @@ public class TextOutput {
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            System.out.println();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue