Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Implementing BookArrayBag Book -title: String - year : int + Book ( title : String, year: int) + getTitle(): String + getYear(): int + setTitle
Implementing BookArrayBag Book -title: String - year : int + Book ( title : String, year: int) + getTitle(): String + getYear(): int + setTitle (title : String): void + setYear (year: int) : void + equals ( obj: Object): boolean + toString(): String BookArrayBag - data : Book[] manyltems : int + BookBag () + BookBag ( capacity: int ) + add (b: Book ) : void + remove (b: Book ) : void + size(): int + grab (index : int ): Book + find (b: Book): Book + countOccurrences (b:Book): int + toString(): String + max(): Book *Two books are equal when they have the same title (case insensitive). ICS 240-50: Introduction to Data Structures - Spring 2022 Consider the BookArrayBag application from slide #6 in the lecture-03-jan-28.pptx. Consider also the following BookArrayBagDriver. 8 public class BookArrayBagDriver { 9 public static void main (String args[]) { 10 BookArrayBag myBag = new BookArrayBag(5); 11 myBag.add(new Book ("Database", 2011)); 12 myBag.add(new Book ("Operating Systems", 1991)); 13 Book algorithms = new Book("Algorithms", 1991); 14 myBag.add(algorithms); 15 16 System.out.println(myBag); System.out.println(myBag.size()); System.out.println(myBag.grab(2)); System.out.println(myBag.find(new Book ("Database", 0))); Book programming = new Book("programming", 0); if (myBag.find(programming)==null) myBag.add(programming); System.out.println(myBag); myBag.remove(new Book("algorithms",0)); System.out.println(myBag.countOccurances (algorithms)); myBag.remove(new Book ("Database",0)); System.out.println(myBag.grab(0)); } 35 } 26 Fill in the following table to show what is printed on the screen or to show the data array of the myBag instance. Line 16: Draw data array Line 17 output: Line 18 output: Line 21 output: Line 27 draw data array: Line 30 draw data array: Line 30 output: Line 33 draw data array: Line 33 output
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started