Question: Complete the implementation of the LinkedStack class by implementing the peek(), isEmpty(), size() and toString() method. Design and create a class named Painting. Test all

  1. Complete the implementation of the LinkedStack class by implementing the peek(), isEmpty(), size() and toString() method.

  2. Design and create a class named Painting.

  3. Test all the methods in the Painting class as well as those in LinkedStack. You must test the Painting methods through objects on the on the Stack, not as an object itself.

  4. Include Javadoc in StackInterface, and generate Javadoc so that you have the doc folder in your project.

  5. Use the logically correct packaging structure to group your classes.

  6. Implement the toString method of StackInterface correctly. When used, it should print out the top element first and the bottom element last. Must test the toString method several times to show that it is not obliterating the stack.

  7. Use the following code as a base.

LinkedStack Class

package stack;

import exception.StackException;

public class LinkedStack implements StackInterface { private LinearNode top; private int count; public LinkedStack() { top = null; count = 0; } public LinkedStack(T element) { LinearNode node = new LinearNode(element); top = node; count = 1; }

public void push(T element) { LinearNodenode = new LinearNode(element); // if(count == 0) { // top = node; // } // else { // node.setNext(Top); // top = node; // } if(count != 0) node.setNext(top); top = node; count++; } public T pop()throws StackException{ if (count == 0) throw new StackException(); T temp = top.getElement(); top = top.getNext(); count--; return temp; } public T peek() throws StackException{ public int size() { public boolean isEmpty() { public String toString() { } } } }

StackException Class

package exception;

public class StackException extends RuntimeException { public StackException(){ super("The stack is empty"); } public StackException(String msg) { super(msg); }

} StackInterface

package stack;

import exception.StackException;

public interface StackInterface { public void push(T element); public T pop() throws StackException; public T peek() throws StackException; public int size(); public boolean isEmpty(); public String toString();

}

LinearNode Class

package stack;

public final class LinearNode { private T element; private LinearNode next; public LinearNode() { element = null; next = null; } public LinearNode(T element) { this.element = element; next = null; } public void setElement (T element) { this.element = element; } public void setNext(LinearNode node) { next = node; } public T getElement() {return element;} public LinearNode getNext() { return next;} public String toString() { return "" +element; }

} Painting Class:

Objectives:

Successful and correct implementation of the Painting Class

Test all six methods of the Stack implementation: pop, push, isEmpty, toString, size, peek using the two stack of your own classes.

Test all the methods in the Painting class you created yourself through the LinkedStack object.

Implementation of the six methods in the Stack class.

pop, push, isEmpty, size, peek. toString

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!