Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Will someone please help me with this Assignment for Java (Data Structures and Algorithms) I am having a real hard time getting started. The assignment

Will someone please help me with this Assignment for Java (Data Structures and Algorithms) I am having a real hard time getting started. The assignment is posted below. Thanks.

Pile of Book

Imagine a pile of books on your desk. Each book is so large and heavy that you can remove only the top one from the pile. You cannot remove a book from under another one. Likewise, you cannot add a book beneath another one. You can add another book to the pile only by placing it on the top of the pile.

If you represent books by their titles alone, design a class that you can use to track the books in the pile on your desk. Specify each operation by stating its purpose, by describing its parameters, and by writing a pseudocode version of its header. Then write a Java interface for the piles methods. Include javadoc-style comments in your code.

Define a class PileOfBooks that implements this interface. Use a resizable array in your implementation. Then write a program that adequately demonstrates your implementation.

In this program, you will need to have 1 class with the name as PileOfBooks, 1 interface with the name as PileInterface, and 1 test class to test everything.

The followings are how books are added the 1st time in your test class:

myPile.add("And Then There Were None");

myPile.add("The Hobbit");

myPile.add("The Lord of the Rings");

myPile.add("The Da Vinci Code");

myPile.add("The Catcher in the Rye");

Then you will need to add another pile of books later.

You will need to create the following methods: add, remove, getTopBook, isEmpty, clear.

The add method should add a new book to the top of this pile.

The remove method should remove and return this pile's top book.

The getTopBook method should retrieve this pile's top book.

The isEmpty method should detect whether this pile is empty.

The clear method should remove all books from this pile.

Make sure to make the Implementation Secure. You will need to create the following private methods: checkintegrity, checkCapacity, doubleCapacity, isArrayFull.

Please make the DEFAULT_CAPACITY = 4;

MAX_CAPACITY = 10000;

Throws an exception if the client requests a capacity that is too large. (IllegalStateException).

Throws an exception if receiving object is not initialized. (SecurityException)

(Please produce the result as the sample run.)

Here is a sample run:

Create an empty pile of books:

isEmpty() returns true

Add to pile.

isEmpty() returns false

Testing peek and pop:

The Catcher in the Rye is at the top of the pile.

The Catcher in the Rye is removed from the pile.

The Da Vinci Code is at the top of the pile.

The Da Vinci Code is removed from the pile.

The Lord of the Rings is at the top of the pile.

The Lord of the Rings is removed from the pile.

The Hobbit is at the top of the pile.

The Hobbit is removed from the pile.

And Then There Were None is at the top of the pile.

And Then There Were None is removed from the pile.

The pile should be empty:

isEmpty() returns true

Add to the pile.

Testing clear:

The pile should be empty: isEmpty() returns true

myPile.getTopBook() returns null

myPile.remove() returns null

Done.

PreviousNext

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions