Class Book
java.lang.Object
it.unimi.di.prog2.h14.member.Book
- All Implemented Interfaces:
Iterable<Book.Chapter>
A (promise of a) book, made up of chapters.
A book is the promise of an author to its editor, the author will first establish a title, then he will add chapters to the book.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<Book.Chapter> The chapters of this book.private final StringThe title of this book. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChapter(String title) Adds a chapter with the given title to this book.iterator()toString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
title
The title of this book. -
chapters
The chapters of this book.
-
-
Constructor Details
-
Book
Creates a book with the given title.The book initially has no chapters.
- Parameters:
title- the title of this book.- Throws:
NullPointerException- if title is null.IllegalArgumentException- if title is empty.
-
-
Method Details
-
addChapter
Adds a chapter with the given title to this book.- Parameters:
title- the title of the chapter to add.- Throws:
NullPointerException- if title is null.IllegalArgumentException- if title is empty.
-
iterator
- Specified by:
iteratorin interfaceIterable<Book.Chapter>
-
toString
-