Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Create code for this UML diagram for the class DropOutStack that also meets below requirements. Has to be a mutator and accessor for maxSize,

Java Create code for this UML diagram for the class DropOutStack that also meets below requirements.

Has to be a mutator and accessor for maxSize, mutator needs to throw a runtime exception if parameter is less than 1.

Default maxSize should be 10 or will depend on constructor's integer parameter. Returned array result of popStack is dependent on parameter's value.

top behaves same way as normal link-based stack.

popStack has one integer parameter refer to as capacity. if capacity exceeds stacks size, a runtime exception will be thrown otherwise it will return an array consisting of capacity elements.

push/pop no increment/decrement statements. Since there is no count attribute may have to use size and isEmpty in a different way.

For push check capacity limit after new element is added.

UML diagram for DropOutStack

-maxSize: int

-top: LinearNode

+DropOutStack()

+DropOutStack(max: int)

+DropOutStack(elem: T)

+DropOutStack(elem: T, max: int)

+popStack(capacity: int):T[capacity]

+setMaxSize(max: int): void

+getMaxSize(): int

This class uses stack adt interface and linear node

StackADT code

public interface StackADT

{

public void push(T element);

public T pop();

public T peek();

public boolean isEmpty();

}

LinearNode Code

public class LinearNode

{

private LinearNode next;

private T element;

public LinearNode()

{

this(null);

}

public LinearNode(T elem)

{

next = null;

element = elem;

}

public LinearNode getNext()

{

return next;

}

public T getElement()

{

return element;

}

public void setNext(LinearNode node)

{

next = node;

}

public void setElement(T elem)

{

element = elem;

}

}

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

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions

Question

What is the best time for a firm to develop its business model?

Answered: 1 week ago

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago