Creating the stack classes

Assignment Help Basic Computer Science
Reference no: EM131544420

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<T> 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.

Reference no: EM131544420

Questions Cloud

What should be the delta to create a riskless portfolio : If the investor writes a call option with a strike price of $43, what should be the delta to create a riskless portfolio?
How to install dns and configuration : You will cover how to install DNS and configuration it, including the DNS tree. Also, the installation and configuration of DHCP should be covered.
Review the asian american brief historical chronology : Choose one historical event that is, in your view, the most serious violation of constitutional rights that should have protected Asian Americans from legal.
What is the amount of commission that bart must pay : what is the amount of commission that Bart must pay?
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.
How many put option contracts are required : Suppose you hold LLL employee stock options representing options to buy 10,400 shares of LLL stock. How many put option contracts are required?
Explain the major differences between the family disease : Explain the major differences between the family disease models, family systems models, and behavioral models of family treatment of addictive behaviors
Which word most closely translates the japanese word kami : A Jewish family in Tucson, Arizona, erects a simple outdoor booth during Sukkot. If you asked them why, what might be their response?
Determine the cost of each capital component : Determine the cost of each capital component. Determine the weighted average cost of capital (WACC) for LEI.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd