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

Have any Question?


Related Questions in Java

Can someone help me please with those question1what is the

Can someone help me please with those question 1:what is the best data type for student id datatime,currency,number,decimal 2:which relationshipis preferable? one to one,one to many,many to many 3:if you add table A's pr ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

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

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

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

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

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

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

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

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

  • 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