Added commands as cases.
This commit is contained in:
		
							parent
							
								
									eb896677e3
								
							
						
					
					
						commit
						62fa36bb42
					
				| 
						 | 
					@ -1,49 +1,8 @@
 | 
				
			||||||
import java.util.ArrayList;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class TextEditor {
 | 
					public class TextEditor {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private SystemInput sysInput;
 | 
					 | 
				
			||||||
    private Text text;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static void main(String[] args) {
 | 
					    public static void main(String[] args) {
 | 
				
			||||||
        TextEditor t = new TextEditor();
 | 
					        TextLogik t = new TextLogik();
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public TextEditor() {
 | 
					 | 
				
			||||||
        sysInput = new SystemInput();
 | 
					 | 
				
			||||||
        text = new Text();
 | 
					 | 
				
			||||||
        String command[];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        do {
 | 
					 | 
				
			||||||
            command = sysInput.checkForInput();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            switch (command[0]) {
 | 
					 | 
				
			||||||
                case "ADD":
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case "DEL":
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case "DUMMY":
 | 
					 | 
				
			||||||
                    text.dummy();
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case "EXIT":
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case "FORMAT RAW":
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case "FORMAT FIX":
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case "INDEX":
 | 
					 | 
				
			||||||
                    ArrayList<String> index = text.index();
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case "PRINT":
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case "REPLACE":
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                default:
 | 
					 | 
				
			||||||
                    System.out.println("Command not found. Try again");
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        } while ("EXIT".equals(command[0]));
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,5 @@
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class TextLogik {
 | 
					public class TextLogik {
 | 
				
			||||||
    private Text text;
 | 
					    private Text text;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,14 +13,30 @@ public class TextLogik {
 | 
				
			||||||
            switch (command[0]) {
 | 
					            switch (command[0]) {
 | 
				
			||||||
                case "ADD":
 | 
					                case "ADD":
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                case "REMOVE":
 | 
					                case "DEL":
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case "Dummy":
 | 
				
			||||||
 | 
					                    text.dummy();
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case "EXIT":
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case "FORMAT RAW":
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case "FORMAT FIX":
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case "INDEX":
 | 
				
			||||||
 | 
					                    ArrayList<String> Index = text.index();
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case "PRINT":
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case "REPLACE":
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                default:
 | 
					                default:
 | 
				
			||||||
                    System.out.println("Command not found. Try again");
 | 
					                    System.out.println("Command not found. Try again");
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } while ("exit".equals(command[0]));
 | 
					        } while ("EXIT".equals(command[0]));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue