Skip to content

Instantly share code, notes, and snippets.

@mishadoff
Created June 22, 2012 08:15
Show Gist options
  • Save mishadoff/2971273 to your computer and use it in GitHub Desktop.
Save mishadoff/2971273 to your computer and use it in GitHub Desktop.
// Assume all following objects have id-constructor
// Book (int id) { this.bookId = id; }
// first book with 1 page and 8 words
Book book1 = new Book(1);
ArrayList<Page> pages = new ArrayList<Page>(); // create holder for pages
Page page1 = new Page(1); // create page
pages.add(page1); // bind page to pages
ArrayList<Word> words = new ArrayList<Word>(); // create holder for words
// filling words list
words.add(new Word(1));
words.add(new Word(2));
// more words here
words.add(new Word(8));
page1.setWords(words); // bind words to page
book1.setPages(pages); // bind pages to book
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment