Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

There are some errors in this code I want you to fix it and please make it clear public class BookProcessor { private Book[] books;

There are some errors in this code I want you to fix it and please make it clear

public class BookProcessor {

private Book[] books; // Array to store Book object references

private int numBooks = 0; // Keeps count of books added into the array

private BookComparator bc;

public BookProcessor() {

// Instantiate the array to a length of 10

for ( int i=0; i<10; i++) {

books[i]=new Book();

}

// Instantiate BookComparator

bc = new BookComparator();

}

public void addBook(Book bk) throws BookException {

if(bk.bookID < 0)

throw new BookException("Invalid BookId!!");

else {

books[numBooks] = bk;

numBooks++;

}

}

public void sortBooksRecurse(int startIndex) {

// import java.util.Array

Arrays.sort(books, new SortBybookID);

// This will sort all the books, but there might be some empty elements in the array, to sort elemtns which really exists use "Arrays.sort(books, new SortBybookID, startIndex, numBooks)"

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions

Question

=+Exhibit children's artwork?

Answered: 1 week ago

Question

What Is acidity?

Answered: 1 week ago

Question

Explain the principles of delegation

Answered: 1 week ago

Question

State the importance of motivation

Answered: 1 week ago

Question

Discuss the various steps involved in the process of planning

Answered: 1 week ago

Question

What are the challenges associated with tunneling in urban areas?

Answered: 1 week ago

Question

b. Will new members be welcomed?

Answered: 1 week ago

Question

c. Will leaders rotate periodically?

Answered: 1 week ago

Question

b. Will there be one assigned leader?

Answered: 1 week ago