Guest User

Untitled

a guest
Jan 17th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.09 KB | None | 0 0
  1. package ui;
  2.  
  3. import java.io.File;
  4. import java.io.FileNotFoundException;
  5. import javax.swing.JOptionPane;
  6.  
  7. import domainmodel.Bib;
  8. import domainmodel.Database;
  9. import domainmodel.Item;
  10. import domainmodel.ItemFactory;
  11.  
  12. public class UI {
  13.  
  14.     /**
  15.      * @param args
  16.      */
  17.    
  18.     public static void main(String[] args) {
  19.         // TODO Auto-generated method stub
  20.        
  21.        
  22.         String type = JOptionPane.showInputDialog(null,"Welke type item wilt u toevoegen van item?");
  23.         String id = JOptionPane.showInputDialog(null,"Welk ID heeft dit item?");
  24.         String titel = JOptionPane.showInputDialog(null, "Geef de titel van het item?");
  25.        
  26.         File data = new File("Data.txt");
  27.  
  28.        
  29.         Bib bib = new Bib("Bib Brussel");
  30.         Database databaseOne = new Database();
  31.    
  32.         ItemFactory builder = new ItemFactory();
  33.         Item item = builder.createItem(type, id, titel);
  34.         bib.addItem(item);
  35.        
  36.        
  37.         try{
  38.         int x = -1;
  39.         while (x != 0) {
  40.             //databaseOne.leesUitBestand(data);        
  41.             String txt = "";
  42.             txt = JOptionPane.showInputDialog(null,"Toon assortiment van " + bib.getnaam() +" druk 1"+"\n druk 2 om nog een item toe te voegen"+" \n druk 3 om item te zoeken in bib " +" \n druk 100 om de toepassing af te sluiten");
  43.             x = Integer.parseInt(txt);
  44.            
  45.             if(x == 1)
  46.             {
  47.                 JOptionPane.showMessageDialog(null, bib.toString());               
  48.             }
  49.            
  50.              if ( x == 2)
  51.             {
  52.                  String type2 = JOptionPane.showInputDialog(null,"Welke type item wilt u toevoegen van item?");
  53.                     String id2 = JOptionPane.showInputDialog(null,"Welk ID heeft dit item?");
  54.                     String titel2 = JOptionPane.showInputDialog(null, "Geef de titel van het item?");
  55.                     Item item2 = builder.createItem(type2, id2, titel2);
  56.                     bib.addItem(item2);
  57.  
  58.             }
  59.              
  60.              if( x == 3 )
  61.              {
  62.                  String zoekID = JOptionPane.showInputDialog(null,"Geef ID van het item dat u zoekt");
  63.                 JOptionPane.showMessageDialog(null, bib.getItem(zoekID));
  64.              }
  65.                
  66.              if( x == 100)
  67.              {
  68.                  databaseOne.schrijfNaarBestand(bib,data);
  69.                  x = 0;
  70.                  
  71.                  
  72.              }
  73.        
  74.         }
  75.        
  76.    
  77.     }
  78.     catch(FileNotFoundException e)
  79.     {
  80.         e.printStackTrace();
  81.  
  82.     }
  83.  
  84. }
  85. }// end UI
Add Comment
Please, Sign In to add comment