Even complicated and confusing topics will be easily developed and covered if you request our help writing an essay. Place an order today!

It is often the case that new data structures are written using other existing data structures as an underlying model. In this practice exercise we will be creating a Stack class using Java’s ArrayList as a basis for our new class.

A Stack data structure behaves similarly to a stack of papers. There are restrictions on adding or removing papers from the stack:
1. You may only add papers to the top of a stack, referred to as a “push” operation.
2. You may only remove papers from the top of a stack, referred to as a “pop” operation.
3. You may also view the paper on top of the stack, referred to as a “peek” operation. This does not remove the top paper.
4. You cannot access papers below the top paper on your stack
Because of these restrictions, a Stack data type is referred to as a LIFO structure (last-in-first-out).

Note: because we only allow access to elements at the top of a Stack, this removes the index-based access of structures such as Arrays and ArrayLists

Write a new Stack class using an ArrayList as the underlying storage structure (in other words, a private instance field). You can simulate the behavior described above by adding/removing items from one side of your ArrayList. Which side to use is up to you, but I would suggest analyzing which side of an ArrayList is best to use.

Use the following class diagram as a basis for your class:

Stack<T>

– data : ArrayList<T>

+ Stack()

+ pop() : T
+ push(newElement : T) : void
+ peek() : T
+ isEmpty() : boolean
+ size() : int

Note: your Stack<T> class should throw an appropriate exception when pop() is called on an empty Stack.

Write a driver class to show that your Stack class is working correctly.

Challenge: create a new class called BoundedStack that enforces a maximum number of elements in your stack.
1. Use the code from your Stack class as a starting point in your new BoundedStack class
2. Include only a parameterized constructor that takes a positive integer that specifies the maximum number of elements in your bounded stack
3. Throw an appropriate exception if you stack size exceeds the bounds given

The post Using Java’s ArrayList appeared first on MBA Nursing Papers.

 

"Are you looking for this answer? We can Help click Order Now"

testimonials icon
At the next meeting, you and the team had a very productive discussion on your findings related to the human resource planning and related team man...
testimonials icon
Fascell quotation | English homework help Task...
testimonials icon
Promt:There is something wrong with how people talk and behave in the " Leaving the Atocha Station", cartoon " Royal Pudding", and the movie...
testimonials icon
An investor is forming a portfolio by investing $75,000 in stock A that has a beta of 1...
testimonials icon
 Fill out all sections of the form with the information requested. You  are expected to use professional, academic writing skills and proper APA...
testimonials icon
DDBA 8161 Week 7 Assignment: Annotated Bibliography on Value Creation Through Diversification *****) To prepare for this Assignment, select four...
testimonials icon
NOVICE TO EXPERT BY PATRICIA BENNERAnalyze the applicability of the theoryA) structureExplicitly and Implicitly describe concepts...
testimonials icon
Question 1 (Multiple Choice Worth 5 points)[LC]Read these lines from Fredrick Douglass's speech "What to The Slave Is the Fo...
testimonials icon
Some exporters report that they value above all the broad exposure afforded through exhibiting at a trade show, regardl...
testimonials icon
Causes of the American RevolutionNameDateInstitutionINTRODUCTION.REVOLUTION IN AMERICA STARTED IN THE YEAR 17...
testimonials icon
EVIDENCE-BASED PRACTICES IN OB/GYN NURSING WITH FOCUS ON BREASTFEEDINGPaper instructions:1. Consider the nursing care delivery models d...
testimonials icon
Describe the key concepts underlying community activism and give examples of how each of these concepts applies to a specific context....

Other samples, services and questions:

Calculate Price

When you use PaperHelp, you save one valuable — TIME

You can spend it for more important things than paper writing.

Approx. price
$65
Order a paper. Study better. Sleep tight. Calculate Price!
Created with Sketch.
Calculate Price
Approx. price
$65