Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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.

Java, Programming

  • Category:- Java
  • Reference No.:- M9717244

Have any Question?


Related Questions in Java

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Question slideshows or carousels are very popular in

Question : Slideshows (or carousels) are very popular in websites. They allow web developers to display news or images on the website in limited space. In this code challenge, you are required to complete the JavaScript ...

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Simple order processing systemquestion given the classes

Simple Order Processing System Question: Given the classes Ship (with getter and setter), Speedboat, and SpeedboatTest. Answer the following questions: Refine the whole application (all classes) and create Abstract class ...

Can someone kindly help me to consider whether java

Can someone kindly help me to consider whether Java provides the facility of operator overloading? If it does, may you kindly describe how overloading operators can be accomplished? If not, may you kindly describe why yo ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As