Represent one book in java

Assignment Help JAVA Programming
Reference no: EM131560

Each instance of this class will represent one book. A book consists of the title of the book, a String, and the author(s). Since books can have an arbitrary number of authors, you are to use an ArrayList of String to hold the authors.

The title of the book is passed to the constructor (see below). The author(s) of the book may, or may not, be supplied when the instance is created. Authors can be added to the book. The authors should be kept in the order in which they were added (not necessarily alphabetical). Authors usually agree on the order of their names for the book, and we will maintain them in that order.

Constructors:

• A constructor that takes a single argument, a String, that is the title of the book.

• A second constructor that takes two arguments: a String that is the title of the book and an ArrayList of String that contains the authors.
Methods:

• set and get methods for the title. The get method for the title returns a String.

• get method for the authors that returns an ArrayList containing String's.

• addAuthor: will take a String and return a void. This author is added to the end of the current list of authors for the book. The method should verify that the author is not already in the list of authors. If the author is already present in the list of authors, then the method simply returns. Each author of a book should appear exactly once.

• toString: will return a String that has the title of the book, followed on separate lines by each of the authors. The title is preceded by the phrase "Title: " - note there is one space after the colon. Each author name is indented three spaces.

• equals: Takes an Object. The object will be a String, but is declared as an Object. The method will test whether the argument is, or is not, the same as the title of the book. Note: the authors are not part of this comparison.

• compareTo: Takes a Title argument. Returns the result of the compareTo method of String applied to the titles (not the authors).

Methods:

• addTitle: will take a String and return a boolean. If the title is already present in the list of books, return false. If the title is not present in the list of books, then add the title to the list in alphabetical order.

• findTitle: will take a String and return a Title. If the title is not present in the list of books, return null. If the Title is present in the list of books, then return a reference to the Title.

• remove: will take a String and return a boolean. If the title is present in the list of books, then remove the title and return true. If the title is not present in the list of books, then return false.

• toString: will return a String containing all the titles and authors. The titles should be in alphabetical order. The authors for each book will be in the order speci?ed when the authors were added to the title.

• toStringTitles: will return a String containing all the titles, one title to a line. The titles should be in alphabetical order. No authors will appear in this String.

Reference no: EM131560

Questions Cloud

Perform the acl test : Perform the ACL test and prepare a report with your conclusions
Examined the effect of body position on blood pressure : Examined the effect of body position on blood pressure
Evaluate effective annual yield : What is the current yield on the bonds?
Building instruction set simulators : Building Instruction Set Simulators
Represent one book in java : Represent one book in java
An efficient human identification using gait analysis : An Efficient Human Identification Using Gait Analysis, Apply specific approach for Pattern Recognition,Implement this approach in MATLAB,Compare and discuss the results with others.
Write a program that pulls four quarterly sales figure : Write a program that Pulls four quarterly sales figure
Post the journal entries to general ledger accounts : Post the journal entries to general ledger accounts. and Prepare a trial balance at November 30.
Average price-earnings ratio : What is the industry average price-earnings ratio?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Java project

Prompt the user for an int between lower and upper boundary.

  Implement avl tree

Implement AVL trees that allows both iterative traversal and recursive traversal.

  Technical community blog

Write a blog article for a coding/technical community blog

  Design and implement a small and simple email server

Design and implement a small and simple email server using the concept of web based information system (WBIS).

  Communication with an smtp server

Develop a graphical user interface based java program that can communicate with a real SMTP email server for sending emails

  Cascading style sheet to a website

Compare and contrast the process of adding JavaScript and a Cascading Style Sheet to a Website. Determine if they can be used simultaneously in a page.

  Create a class safestack that implements a stack of strings

Create a class SafeStack that implements a stack of strings

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Mvc pattern and servlet

When you use the MVC pattern, the controller directs the flow of control to

  Compilation and Execution - JAVA problem

Style marks are based on how your submitted code looks. Remember that good code is easily readable (and understandable) by someone who did not write it. For assignments, you should also include your name, student number, what course this is, what ass..

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Determine if strings are equal

Complete the recursive method match in the code below which will determine whether or not two strings match.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd