Advertisement
Guest User

CollectionController

a guest
Oct 12th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package scenebuilderexample;
  7.  
  8. import java.time.LocalDate;
  9. import java.util.ArrayList;
  10. import java.util.Scanner;
  11. import javafx.collections.FXCollections;
  12. import javafx.collections.ObservableList;
  13. import model.Author;
  14. import model.Book;
  15.  
  16. import model.CollectionOfBooks;
  17.  
  18. public class CollectionController {
  19.  
  20. CollectionOfBooks collection = new CollectionOfBooks();
  21.  
  22. public void addBookClicked()
  23. {
  24. Scanner scanner = new Scanner(System.in);
  25. ArrayList<Author> authors = new ArrayList();
  26.  
  27.  
  28.  
  29.  
  30. String nameOfBook = "Harry potter";
  31. String ISBN = "123123";
  32. String authorName = "David Guirguis";
  33. authors.add(new Author(authorName, LocalDate.now())); //create author
  34.  
  35.  
  36. collection.addBook(ISBN, nameOfBook, authors); //create book with title, isbn and author/s
  37.  
  38.  
  39. }
  40.  
  41. public void listBooksClicked()
  42. {
  43. ArrayList<Author> authors = new ArrayList();
  44. String authorName1 = "David Guirguis";
  45. String authorName2 = "Henric Andersson";
  46. authors.add(new Author(authorName1, LocalDate.now())); //create author
  47. authors.add(new Author(authorName2, LocalDate.now())); //create author
  48.  
  49.  
  50.  
  51. ArrayList<Book> searchResult = new ArrayList(); //new arraylist, used as copy of books
  52.  
  53. ObservableList<Book> searchResultt = FXCollections.observableArrayList(
  54. new Book("12323", "Harry Potter", authors),
  55. new Book("123145", "Sagan om Ringen", authors)
  56. );
  57.  
  58. searchResult = collection.showAllBooks(); //recieves all books, sorted
  59. System.out.println("Printing");
  60. for(Book b : searchResult)
  61. {
  62. System.out.println(b.toString());
  63. }
  64.  
  65. }
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement