/** Java class "Labb2Menu.java" generated from Poseidon for UML. * Poseidon for UML is developed by Gentleware. * Generated with velocity template engine. */ import java.util.*; import java.io.*; public class Labb2Menu { /////////////////////////////////////// // attributes private final String menu = "\ncustomer info(c) customer update(u) new order(o) quit(q)\n"; /////////////////////////////////////// // associations private DbInterface dbConnection; /////////////////////////////////////// // operations public Labb2Menu(DbInterface dbc) { dbConnection = dbc; } // end Labb2Menu public DbInterface getDbConnection() { return dbConnection; } // end getDbConnection public void run() { dbConnection.open(); boolean running = true; int c; while(running) { System.out.println("\n\nLabb 2" + dbConnection.toString() + menu); try { c = System.in.read(); } catch(java.io.IOException e) { return; } switch(c) { case 'q' : running = false; break; case 'c' : customerInfo(); break; case 'u' : customerUpdate(); break; case 'o' : addOrder(); break; } } dbConnection.close(); } // end run public void customerInfo() { try { System.out.println("Vilken kund? "); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String name = in.readLine(); name = in.readLine(); System.out.println(dbConnection.getCustomer(name)); } catch(IOException e) { System.err.println(e.toString()); } } // end customerInfo public void customerUpdate() { try { System.out.println("Vilken kund? "); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String name = in.readLine(); name = in.readLine(); System.out.println("Vilken gata? "); String street = in.readLine(); System.out.println("Vilken stad? "); String city = in.readLine(); System.out.println(dbConnection.updateCustomer(name, street, city)); } catch(IOException e) { System.err.println(e.toString()); } } // end customerUpdate public void addOrder() { // your code here } // end addOrder } // end Labb2Menu