/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package referencelibrary;

/**
 *
 * @author juhapekm
 */
public class UI {
    private IO io;
    
    public void run() {
        io = new ConsoleIO();
        io.print("Reference library");
        printAvailableCommands();
        String command = "q";
        command = io.readLine("\nChoose command: \n");
        while(!command.equals("q")) {
            //call chosen functionality
            switch (command){
                case "a":   addNewReference();
                            break;
                case "g":   generateBixTexFile();
                            break;
            }
            //new command
            printAvailableCommands();
            command = io.readLine("\nChoose command: \n");
        }
        io.print("Ohjelma loppuu..");
    }
    
    public void printAvailableCommands() {
        io.print("(q)uit," + "\n" + "(a)dd new reference," + "\n" + "(g)enerate bibtex" + "\n");
    }
    
    public void addNewReference() {
        io.print("Add new reference");
        //switch: reference type
            //call appropriate adding method
        io.print("--adding not implement");
        
        io.print("Reference added!");
    }
    
    public void generateBixTexFile() {
        io.print("Generating bibTex -file");
        //call bibtex-file generator
        io.print("--generating not implemented");
        
        io.print("Generating done!");
    }
}

@@ -205,16 +205,43 @@
 brary;%0A%0A
+import java.util.HashMap;%0A%0A
 /**%0A *%0A 
@@ -1210,24 +1210,183 @@
 eference%22);%0A
+        %0A        //promt reference type%0A        String command = io.readLine(%22%5CnChoose reference type: %5Cn%22);%0A        io.print(%22(B)ook, %5Cn(O)ther%5Cn%22);%0A        %0A
         //sw
@@ -1389,18 +1389,18 @@
 //switch
-:
  
+(
 referenc
@@ -1397,32 +1397,33 @@
  (reference type
+)
 %0A            //c
@@ -1419,50 +1419,232 @@
     
- 
+switch(command)%7B%0A            case %22B%22:
    //
-c
+C
 all a
-ppropriate adding method%0A     
+ddBook%0A                        io.print(%22--adding not implement%22);%0A                        //io.print(%22Reference added!%22);%0A                        break;%0A            case %22O%22:
    i
@@ -1682,33 +1682,37 @@
 %22);%0A        
-%0A
+     
         
 io.print(%22Re
@@ -1691,32 +1691,37 @@
                 
+   //
 io.print(%22Refere
@@ -1730,24 +1730,693 @@
 e added!%22);%0A
+                        break;%0A        %7D %0A    %7D%0A    %0A    public void addNewBook() %7B%0A        String referenceType = %22Book%22;%0A        String referenceName = io.readLine(%22Reference id%22);%0A        String author = io.readLine(%22Author: %22);%0A        String title = io.readLine(%22Title: %22);%0A        String year = io.readLine(%22Year: %22);%0A        String publisher = io.readLine(%22Publisher: %22);%0A        HashMap%3CString, String%3E newRefHash = new HashMap%3CString, String%3E();%0A        newRefHash.put(%22author%22, author);%0A        newRefHash.put(%22title%22, title);%0A        newRefHash.put(%22year%22, year);%0A        newRefHash.put(%22publisher%22, publisher);%0A        //Reference newRef = new Reference();%0A
     %7D%0A    %0A 

add 'add book'-functionality to UI