Fixed bugs in TextLogic Commands Replace and Del
This commit is contained in:
		
							parent
							
								
									2bb76acb46
								
							
						
					
					
						commit
						3ce98df973
					
				| 
						 | 
				
			
			@ -27,13 +27,12 @@ public class TextLogik {
 | 
			
		|||
 | 
			
		||||
                    break;
 | 
			
		||||
                case "DEL":
 | 
			
		||||
                    if (command.length == 1){
 | 
			
		||||
                        text.del(TextInput.checkForInput().length);
 | 
			
		||||
                    }else if (isNumeric(command[1])){
 | 
			
		||||
                    if (command.length == 1) {
 | 
			
		||||
                        text.del();
 | 
			
		||||
                    } else if (isNumeric(command[1])) {
 | 
			
		||||
                        int line = Integer.parseInt(command[1]);
 | 
			
		||||
 | 
			
		||||
                        text.del(line, text.size () - 1);
 | 
			
		||||
                    }else {
 | 
			
		||||
                        text.del(line);
 | 
			
		||||
                    } else {
 | 
			
		||||
                        textOutput.errorInvalidCommand();
 | 
			
		||||
                    }
 | 
			
		||||
                    break;
 | 
			
		||||
| 
						 | 
				
			
			@ -62,15 +61,15 @@ public class TextLogik {
 | 
			
		|||
                    break;
 | 
			
		||||
                case "REPLACE":
 | 
			
		||||
                    if (command.length == 1){
 | 
			
		||||
                        text.replace(TextInput.getTextInput());
 | 
			
		||||
                        text.replace(TextInput.getTextInput(), TextInput.getTextInput());
 | 
			
		||||
                    }else if(isNumeric(command[1])) {
 | 
			
		||||
                        int line = Integer.parseInt(command[1]);
 | 
			
		||||
 | 
			
		||||
                        text.replace(line, text.size() - 1);
 | 
			
		||||
                        text.replace(line, TextInput.getTextInput(), TextInput.getTextInput());
 | 
			
		||||
                    }else {
 | 
			
		||||
                        textOutput.errorInvalidCommand();
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                    break;
 | 
			
		||||
                default:
 | 
			
		||||
                    System.out.println("Command not found. Try again");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue