Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 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 scenebuilderexample;
- import java.time.LocalDate;
- import java.util.ArrayList;
- import java.util.Scanner;
- import javafx.collections.FXCollections;
- import javafx.collections.ObservableList;
- import model.Author;
- import model.Book;
- import model.CollectionOfBooks;
- public class CollectionController {
- CollectionOfBooks collection = new CollectionOfBooks();
- public void addBookClicked()
- {
- Scanner scanner = new Scanner(System.in);
- ArrayList<Author> authors = new ArrayList();
- String nameOfBook = "Harry potter";
- String ISBN = "123123";
- String authorName = "David Guirguis";
- authors.add(new Author(authorName, LocalDate.now())); //create author
- collection.addBook(ISBN, nameOfBook, authors); //create book with title, isbn and author/s
- }
- public void listBooksClicked()
- {
- ArrayList<Author> authors = new ArrayList();
- String authorName1 = "David Guirguis";
- String authorName2 = "Henric Andersson";
- authors.add(new Author(authorName1, LocalDate.now())); //create author
- authors.add(new Author(authorName2, LocalDate.now())); //create author
- ArrayList<Book> searchResult = new ArrayList(); //new arraylist, used as copy of books
- ObservableList<Book> searchResultt = FXCollections.observableArrayList(
- new Book("12323", "Harry Potter", authors),
- new Book("123145", "Sagan om Ringen", authors)
- );
- searchResult = collection.showAllBooks(); //recieves all books, sorted
- System.out.println("Printing");
- for(Book b : searchResult)
- {
- System.out.println(b.toString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement