Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please I need linked data implementation in java not array You are given IBookPile interface and IBook interface. Implement the IBookPile interface using linked nodeas

please I need linked data implementation in java not array

You are given IBookPile interface and IBook interface. Implement the IBookPile interface using linked nodeas

You will need to write a Main class that test your implementation.

partial code is here.

public class Main { public static void main(String[] args) { IBook b1 = new Book("Java 1", "Joe"); IBook b2 = new Book("JavaFX 2", "Bill"); IBook b3 = new Book("Database", "Mike"); IBookPile pile = new BookPile(); pile.add(b1); pile.add(b2); pile.add(b3); for(int i=0; i

interface IBook { String getTitle(); }

class Book implements IBook { private String title; private String author; Book(String title, String author){ this.title = title; this.author = author; } public String getTitle(){ return title; } public String getAuthor(){ return author; } }

/** * A pile of very heavy books. A book is so heavy that * only one book can be placed on top of the pile one at a time * and only a book can be removed from the top of the pile one * at a time. No book can be removed */ interface IBookPile { /** * Place the book on top of the bile of books * @param book the book to be placed * @return Return true if successful. */ public boolean add(IBook book); /** * Remove the book from the top of the pile * @return book removed */ public IBook remove(); /** * Return the number of books in the pile * @return number of books in the pile */ public int size(); /** * Return the number of books that have the title. * @param title the title to search * @return number of books matching the title */ int count(String title); /** * Return the titles of all books in the pile * @return array of titles */ public String[] getTitles(); /** * Return the title of book at position start from bottom. * @param pos position of book * @return The title of the book */ public String getTitleAt(int pos); /** * Return true if pile of books contain such book. * @param title the title of the book. * @return True if there's a book with the title. */ public boolean contains(String title); }

class BookPile implements IBookPile {

public boolean add(IBook book){ throw new UnsupportedOperationException("To be implemented"); }

public IBook remove() { throw new UnsupportedOperationException("To be implemented"); }

public int size(){ throw new UnsupportedOperationException("To be implemented"); }

public int count(String title){ throw new UnsupportedOperationException("To be implemented"); } public String[] getTitles(){ throw new UnsupportedOperationException("To be implemented"); } public String getTitleAt(int pos){ throw new UnsupportedOperationException("To be implemented"); } public boolean contains(String title){ throw new UnsupportedOperationException("To be implemented"); } }

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_2

Step: 3

blur-text-image_3

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

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions

Question

1. Is this appropriate?

Answered: 1 week ago