package bakatxt.core;

import java.util.Scanner;

public class BakaTxtMain {

    private static final String MESSAGE_WELCOME = "Welcome To BakaTxt!";
    private static final String MESSAGE_BYEBYE = "Bye bye!";
    private static final String MESSAGE_ENTER_COMMAND = "Please enter command: ";

    enum CommandType {
        ADD, DELETE, DISPLAY, EXIT;
    }

    private static Scanner _sc;
    private static BakaParser _parser;
    private static Database _database;
    private static String _filename;

    public BakaTxtMain() {
        // TODO this is kludge code - to be removed
        _filename = "mytestfile.txt";
        _sc = new Scanner(System.in);
        _parser = new BakaParser();
        _database = new Database(_filename);
    }

    public static void main(String[] args) {
        BakaTxtMain thisSession = new BakaTxtMain();

        System.out.println(MESSAGE_WELCOME);

        while (true) {
            System.out.print(MESSAGE_ENTER_COMMAND);
            String input = _sc.nextLine();
            String result = executeCommand(input);
            System.out.println(result);
        }
    }

    private static String executeCommand(String input) {
        String command = _parser.getCommand(input);
        CommandType commandType = CommandType.valueOf(command);

        String output = null;
        switch (commandType) {
            case ADD :
                Task toAdd = _parser.add(input);
                boolean isAdded = _database.add(toAdd);
                if (isAdded) {
                    // TODO something when added
                    output = toAdd.toDisplayString();
                } else {
                    // TODO error in adding
                }
                break;

            case DELETE :
                break;

            case DISPLAY :
                break;

            case EXIT :
                System.out.println(MESSAGE_BYEBYE);
                _database.close();
                System.exit(0);
                break;

            default :
        }

        return output;
    }
}

@@ -32,20 +32,85 @@
 ava.
-util.Scanner
+awt.GraphicsEnvironment;%0Aimport java.util.Scanner;%0A%0Aimport bakatxt.gui.BakaUI
 ;%0A%0Ap
@@ -851,24 +851,77 @@
 g%5B%5D args) %7B%0A
+%0A        if (GraphicsEnvironment.isHeadless()) %7B%0A    
         Baka
@@ -962,32 +962,36 @@
 ain();%0A%0A        
+   
+ 
 System.out.print
@@ -1020,16 +1020,20 @@
         
+    
 while (t
@@ -1043,32 +1043,36 @@
 ) %7B%0A            
+   
+ 
 System.out.print
@@ -1104,24 +1104,28 @@
             
+    
 String input
@@ -1151,24 +1151,28 @@
             
+   
+ 
 String resul
@@ -1202,32 +1202,36 @@
 t);%0A            
+    
 System.out.print
@@ -1246,26 +1246,67 @@
 t);%0A        
+   
+ 
 %7D%0A
+        %7D%0A        BakaUI.startGui();%0A
     %7D%0A%0A    p
@@ -1297,38 +1297,37 @@
 ();%0A    %7D%0A%0A    p
-rivate
+ublic
  static String e

Update to add in previous GUI call