Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.) imagine a pile of books on your desk. each book is so large and heavy that y

ID: 3549290 • Letter: 1

Question

1.) 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 can add another book sto the pile only by placing it on the top of the pile. You cannot add a book beneath another one. 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 intergace for the piles methods. Include javadoc-style comments in the code.


2.) Define a class PileOfBooks that implements the interface described in question one. use a resizeable array oin your implementation. then write unit test woth adequate test cases for your implementation of class PiloOfBooks.



I WILL MAKE SURE TO RATE THE BEST ANSWER. THANK YOU VERY MUCH

Explanation / Answer

public class StackDemo

{

private static final int capacity = 3;

String arr[] = new String[capacity];

int top = -1;


public void push(String pushedElement)

{

if (top < capacity - 1)

{

top++;

arr[top] = pushedElement;

System.out.println("Element " + pushedElement

+ " is pushed to Stack !");

printElements();

}

else

{

System.out.println("Stack Overflow !");

}

}


public void pop()

{

if (top >= 0)

{

top--;

System.out.println("Pop operation done !");

}

else

{

System.out.println("Stack Underflow !");

}

}


public void printElements()

{

if (top >= 0)

{

System.out.println("Elements in stack :");

for (int i = 0; i <= top; i++)

{

System.out.println(arr[i]);

}

}

}


public static void main(String[] args)

{

StackDemo stackDemo = new StackDemo();


stackDemo.pop();

stackDemo.push("Maths");

stackDemo.push("English");

stackDemo.push("Science");

stackDemo.push("Sanskrit");

stackDemo.pop();

stackDemo.pop();

stackDemo.pop();

stackDemo.pop();

}


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote