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.

  Implementation activities of software development

Analysis, design, and implementation activities of software development

  Design a course registration system

Create an application which represents a simplified course registration system using ArrayLists and HashMaps.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create a driver class in java

Your project is to create a driver class that uses SuperJavaIceCreamClass.

  Sorted list adt and the binary search tree adt

Explain the differences between our specifications of the Sorted List ADT and the Binary Search Tree ADT.

  Create a project in eclipse

Create a new project

  Design an abstract data type in java

Design an abstract data type in Java that represents a musical pitch

  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..

  World data app

Prepare WorldDataApp project. It implements the NameIndex portion, including creating it in SetupProgram, and searching, viewing and updating it in UserApp program.

  Determine if strings are equal

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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

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