Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Q1) Creating the stack classes

You are required to write your own generic stack implementation in Java that you will use in questions 2 and 3.

a. Create a stack interface Stack that uses a generic type T and has the following abstract methods:

- isEmpty, isFull, peek (returns T), pop(returns T), void push(T), void clear() to clear the contents of the stack, and int size (returns the number of elements in the stack).

- void reverse() reverses the contents of the stack ( in your implementation you can use an additional local stack in your method to help you with the reverse operation.)

- void display() prints out the contents of the stack (Hint: you can obtain the contents of your stack elements using toString())

b. Write your two stack implementations (ArrayStack and ListStack) using the stack interface.

c. Your stack implementations must have all instance variables as private.

d. Both implementations must a constructor that initializes the capacity of the stack. For the ListStack , the stack is full when the size reaches the initial capacity.

e. You must also implement public String toString() in both classes. It returns a String representation of the stack contents.

c. Create a simple main class QuestionOne that creates two stacks of Integers of capacity=20 one that uses the ArrayStack and the other uses the ListStack implementations. Push 20 values in each: in the first (1,2,3,...,20) and in the second (20, 19,..,13,.., 1). Call the following methods for both stacks in the given order: display, reverse, display, peek, pop, pop, reverse, size, isFull, isEmpty, display, clear, display, isEmpty.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92353143
  • Price:- $20

Priced at Now at $20, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Use the management studio to create a new database called

Use the Management Studio to create a new database called Membership2 using the default settings. (If the database already exists, use the Management Studio to delete it and than recreate it)

Remote direct memory access rdma enables efficient memory

Remote Direct Memory Access (RDMA) enables efficient memory access from one computer to another. Read about it using Google Scholar, ACM Digital Library or any professional literature tools. Write a 150-200 words (refere ...

You get hired as a machine learning expert at moviescom

You get hired as a Machine learning expert at movies.com. Your task on day one is to improve the performance of a classifier. You divide the data into 2 parts training, and testing. You learn a model from the training da ...

Submit a proposal of your ideal computer-in narrative form

Submit a proposal of your "ideal" computer-in narrative form. Make sure to answer the following questions: • State the technical specifications of your ideal computer • What would you like your ideal computer to accompli ...

A 2-year treasury security currently earns 197 percent over

A 2-year Treasury security currently earns 1.97 percent. Over the next two years, the real risk-free rate is expected to be 1.00 percent per year and the inflation premium is expected to be 0.60 percent per year. Calcula ...

Question a tank for propane gas is a cylinder with

Question : A tank for propane gas is a cylinder with hemispheres at each end. Write a process that asks the user to enter the length of the cylinder and the radius of the cylinder (same as the radius of the hemisphere (s ...

Question a student study 0 1 2 or 3 hours for a math 307

Question : A student study 0, 1, 2, or 3 hours for a MATH 307 test on any given day. Use the tree diagram to find the total number of ways in which the student can study at most 4 hours for the test on two consecutive da ...

Question please submit your draft apa-formatted research

Question: Please submit your draft APA-formatted research papers through this assignment page. You will have until the end of Week #4 to submit a draft of your paper for consideration as extra credit. This is Part 1 of t ...

Question you are to write a report on the malware assigned

Question: You are to write a report on the malware assigned to you in the "Week 6 Malware assignment by individual student" document. Your report, written in Microsoft Word with 12 point type and 1 in margins, must have ...

Question 1 assume that you are the project manager for an

Question: 1) Assume that you are the project manager for an upcoming new information systems project designed to replace your organization's old inventory management system. The server and database will also be upgraded. ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As