SlideShare a Scribd company logo
(1) The goal is to implement DataStructures.ArrayStack according to the interface ADTs.StackADT
********************************************
package DataStructures;
import ADTs.StackADT;
import Exceptions.EmptyCollectionException;
import Exceptions.StackOverflowException;
public class ArrayStack<T> implements StackADT<T> {
/** The index of where the top of the stack is */
int top;
/** The array that holds the stack */
T[] buffer;
public ArrayStack() {
}
public ArrayStack(int initialCapacity) {
}
}
*******************************************************
package ADTs;
import Exceptions.EmptyCollectionException;
import Exceptions.StackOverflowException;
/**
* An interface for a Stack
* Specific stack implementations will implement this interface
* For use Data Structures & Algorithms
*
*
* author unknown
*/
public interface StackADT<T> extends CollectionADT<T> {
/**
* Adds the specified element to the top of the stack
*
* @param element element to be pushed onto the stack
*/
public void push(T element) throws StackOverflowException;
/**
* Removes and returns the element that is on top of the stack
*
* @return the element removed from the stack
* @throws EmptyCollectionException
*/
public T pop() throws EmptyCollectionException;
/**
* Returns (without removing) the element that is on top of the stack
*
* @return the element on top of the stack
* @throws EmptyCollectionException
*/
public T peek() throws EmptyCollectionException;
}
*****************************************
package ADTs;
import Exceptions.*;
/**
* An interface for an ordered (NOT SORTED) List
* Elements stay in the order they are put in to the list
* For use in Data Structures & Algorithms
*
*
* @author unknown
*/
public interface ListADT<T> extends CollectionADT<T> {
/**
* Adds the specified element to the list at the front
*
* @param element: the element to be added
*
*/
public void addFirst(T element);
/**
* Adds the specified element to the end of the list
*
* @param element: the element to be added
*/
public void addLast(T element);
/**
* Adds the specified element to the list after the existing element
*
* @param existing: the element that is in the list already
* @param element: the element to be added
* @throws ElementNotFoundException if existing isn't in the list
*/
public void addAfter(T existing, T element) throws ElementNotFoundException,
EmptyCollectionException;
/**
* Removes and returns the specified element
*
* @return the element specified
* @throws EmptyCollectionException
* @throws ElementNotFoundException
*/
public T remove(T element) throws EmptyCollectionException, ElementNotFoundException;
/**
* Removes and returns the first element
*
* @return the first element in the list
* @throws EmptyCollectionException
*/
public T removeFirst() throws EmptyCollectionException;
/**
* Removes and returns the last element
*
* @return the last element in the list
* @throws EmptyCollectionException
*/
public T removeLast() throws EmptyCollectionException;
/**
* Returns (without removing) the first element in the list
*
* @return element at the beginning of the list
* @throws EmptyCollectionException
*/
public T first() throws EmptyCollectionException;
/**
* Returns (without removing) the last element in the list
*
* @return element at the end of the list
* @throws EmptyCollectionException
*/
public T last() throws EmptyCollectionException;
/**
* Return whether the list contains the given element.
*
* @param element
* @return
* @throws EmptyCollectionException
*/
public boolean contains(T element) throws EmptyCollectionException;
/**
* Returns the index of the given element.
*
* @param element
* @return the index of the element, or -1 if not found
*/
public int indexOf(T element);
/**
* Return the element at the given index of a list.
*
* @param element
* @return
* @throws EmptyCollectionException
*/
public T get(int index) throws EmptyCollectionException, InvalidArgumentException;
/**
* Set the at the given index of a list.
*
* @param element
* @return
* @throws EmptyCollectionException
*/
public void set(int index, T element) throws EmptyCollectionException, InvalidArgumentException;
}
***********************************************
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ADTs;
/**
* An interface for an AbstractDataType
* Specific ADT interfaces will extend this
* For use in Data Structures & Algorithms
*
*
* @author unknown
*/
public interface CollectionADT<T> {
/**
* Returns true if the collection contains no elements
*
* @return true if the collection is empty
*/
public boolean isEmpty();
/**
* Returns the number of elements in the collection
*
* @return the number of elements as an int
*/
public int size();
/**
* Returns a string representation of the collection
*
* @return a string representation of the collection
*/
@Override
public String toString();
}
**********************************
Project must compile (otherwise no grade)
(1) JavaDoc for DataStructures.ArrayStack class
(2) Tests passing for DataStructures.ArrayStack class

More Related Content

PDF
package ADTs public interface CollectionADTltTgt .pdf
DOCX
Java Foundations StackADT-java --- - Defines the interface to a stack.docx
PDF
we using java code DynamicArrayjava Replace all .pdf
PDF
please read below it will tell you what we are using L.pdf
PDF
Modifications highlighted in bold lettersDropOutStack.javaim.pdf
PDF
please read the steps below and it will tell you what we usi.pdf
PDF
Please do parts labeled TODO LinkedList.java Replace.pdf
PDF
we using java dynamicArray package modellinearpub imp.pdf
package ADTs public interface CollectionADTltTgt .pdf
Java Foundations StackADT-java --- - Defines the interface to a stack.docx
we using java code DynamicArrayjava Replace all .pdf
please read below it will tell you what we are using L.pdf
Modifications highlighted in bold lettersDropOutStack.javaim.pdf
please read the steps below and it will tell you what we usi.pdf
Please do parts labeled TODO LinkedList.java Replace.pdf
we using java dynamicArray package modellinearpub imp.pdf

Similar to 1 The goal is to implement DataStructuresArrayStack accor.pdf (20)

DOCX
PDF
Hi,I have added the methods and main class as per your requirement.pdf
DOCX
EmptyCollectionException-java -- - Represents the situation in which.docx
DOCX
Please complete all the code as per instructions in Java programming.docx
DOCX
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
PDF
StackInterface An interface for the ADT stack. Do not modif.pdf
PDF
Note- Can someone help me with the public boolean isEmpty()- public bo.pdf
PDF
Fix my codeCode.pdf
PDF
Implementation The starter code includes List.java. You should not c.pdf
PDF
For this lab you will complete the class MyArrayList by implementing.pdf
PDF
So I have this code(StackInAllSocks) and I implemented the method but.pdf
PDF
STAGE 2 The Methods 65 points Implement all the methods t.pdf
DOCX
Note- Can someone help me with the private E get(int index- int curren (1).docx
PDF
Note- Can someone help me with the Public boolean add(E value) method.pdf
PDF
LabProgram.javaimport java.util.NoSuchElementException;public .pdf
DOCX
@author Derek Harter @cwid 123 45 678 @class .docx
PDF
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdf
PDF
File LinkedList.java Defines a doubly-l.pdf
PDF
In this lab, we will write an application to store a deck of cards i.pdf
PDF
Please help me to make a programming project I have to sue them today- (1).pdf
Hi,I have added the methods and main class as per your requirement.pdf
EmptyCollectionException-java -- - Represents the situation in which.docx
Please complete all the code as per instructions in Java programming.docx
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
StackInterface An interface for the ADT stack. Do not modif.pdf
Note- Can someone help me with the public boolean isEmpty()- public bo.pdf
Fix my codeCode.pdf
Implementation The starter code includes List.java. You should not c.pdf
For this lab you will complete the class MyArrayList by implementing.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdf
STAGE 2 The Methods 65 points Implement all the methods t.pdf
Note- Can someone help me with the private E get(int index- int curren (1).docx
Note- Can someone help me with the Public boolean add(E value) method.pdf
LabProgram.javaimport java.util.NoSuchElementException;public .pdf
@author Derek Harter @cwid 123 45 678 @class .docx
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdf
File LinkedList.java Defines a doubly-l.pdf
In this lab, we will write an application to store a deck of cards i.pdf
Please help me to make a programming project I have to sue them today- (1).pdf

More from saradashata (20)

PDF
Which one of the following is NOT one of the four key differ.pdf
PDF
When you complete the birth certificate workbook develop a .pdf
PDF
Wohlers amp Co issued convertible bonds with a face value.pdf
PDF
Which of the following describes the respiratory membrane in.pdf
PDF
Use a commercial passanger airline company to illustrate a s.pdf
PDF
We discussed in class extensively Porters five forces Two.pdf
PDF
Unilever bir zamanlar ondan fazla farkl amar deterjan marka.pdf
PDF
Use the following Excel payroll register to answer the remai.pdf
PDF
Vaka almas eriden 2011 ylnda bir federal jri tannm bir .pdf
PDF
Todo lo siguiente est asociado con la presentacin de infor.pdf
PDF
The mission of The Walt Disney Company is to be one of the w.pdf
PDF
Segn los autores si una persona hiciera un viaje por carre.pdf
PDF
Tanmlanamayan Sektrler Sonraki iki soruyu cevaplamak iin .pdf
PDF
Report Topic about The difference between growing aging an.pdf
PDF
S 20 alfa 005 1 kuyruk Bo hipotez Madeni para adil .pdf
PDF
Please read this case Case Mrs Z is a 70yearold Pakistani.pdf
PDF
Qu cree que es ms importante el desempeo de la tarea e.pdf
PDF
Quito contracts with Rewind Graphix Inc to pay 5000 for.pdf
PDF
Q no 1 Since she was a child Sunita Arora has had an eye f.pdf
PDF
Pregunta 4 Qu se entiende por contabilidad creativa Usa.pdf
Which one of the following is NOT one of the four key differ.pdf
When you complete the birth certificate workbook develop a .pdf
Wohlers amp Co issued convertible bonds with a face value.pdf
Which of the following describes the respiratory membrane in.pdf
Use a commercial passanger airline company to illustrate a s.pdf
We discussed in class extensively Porters five forces Two.pdf
Unilever bir zamanlar ondan fazla farkl amar deterjan marka.pdf
Use the following Excel payroll register to answer the remai.pdf
Vaka almas eriden 2011 ylnda bir federal jri tannm bir .pdf
Todo lo siguiente est asociado con la presentacin de infor.pdf
The mission of The Walt Disney Company is to be one of the w.pdf
Segn los autores si una persona hiciera un viaje por carre.pdf
Tanmlanamayan Sektrler Sonraki iki soruyu cevaplamak iin .pdf
Report Topic about The difference between growing aging an.pdf
S 20 alfa 005 1 kuyruk Bo hipotez Madeni para adil .pdf
Please read this case Case Mrs Z is a 70yearold Pakistani.pdf
Qu cree que es ms importante el desempeo de la tarea e.pdf
Quito contracts with Rewind Graphix Inc to pay 5000 for.pdf
Q no 1 Since she was a child Sunita Arora has had an eye f.pdf
Pregunta 4 Qu se entiende por contabilidad creativa Usa.pdf

Recently uploaded (20)

PDF
RMMM.pdf make it easy to upload and study
PDF
Basic Mud Logging Guide for educational purpose
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Classroom Observation Tools for Teachers
PDF
Business Ethics Teaching Materials for college
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPTX
Cell Types and Its function , kingdom of life
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Complications of Minimal Access Surgery at WLH
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
RMMM.pdf make it easy to upload and study
Basic Mud Logging Guide for educational purpose
01-Introduction-to-Information-Management.pdf
Renaissance Architecture: A Journey from Faith to Humanism
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Classroom Observation Tools for Teachers
Business Ethics Teaching Materials for college
102 student loan defaulters named and shamed – Is someone you know on the list?
Microbial disease of the cardiovascular and lymphatic systems
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Cell Types and Its function , kingdom of life
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Complications of Minimal Access Surgery at WLH
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
O7-L3 Supply Chain Operations - ICLT Program
Final Presentation General Medicine 03-08-2024.pptx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student

1 The goal is to implement DataStructuresArrayStack accor.pdf

  • 1. (1) The goal is to implement DataStructures.ArrayStack according to the interface ADTs.StackADT ******************************************** package DataStructures; import ADTs.StackADT; import Exceptions.EmptyCollectionException; import Exceptions.StackOverflowException; public class ArrayStack<T> implements StackADT<T> { /** The index of where the top of the stack is */ int top; /** The array that holds the stack */ T[] buffer; public ArrayStack() { } public ArrayStack(int initialCapacity) { } } ******************************************************* package ADTs; import Exceptions.EmptyCollectionException; import Exceptions.StackOverflowException; /** * An interface for a Stack * Specific stack implementations will implement this interface * For use Data Structures & Algorithms * * * author unknown */ public interface StackADT<T> extends CollectionADT<T> { /** * Adds the specified element to the top of the stack * * @param element element to be pushed onto the stack */ public void push(T element) throws StackOverflowException; /** * Removes and returns the element that is on top of the stack * * @return the element removed from the stack * @throws EmptyCollectionException */ public T pop() throws EmptyCollectionException;
  • 2. /** * Returns (without removing) the element that is on top of the stack * * @return the element on top of the stack * @throws EmptyCollectionException */ public T peek() throws EmptyCollectionException; } ***************************************** package ADTs; import Exceptions.*; /** * An interface for an ordered (NOT SORTED) List * Elements stay in the order they are put in to the list * For use in Data Structures & Algorithms * * * @author unknown */ public interface ListADT<T> extends CollectionADT<T> { /** * Adds the specified element to the list at the front * * @param element: the element to be added * */ public void addFirst(T element); /** * Adds the specified element to the end of the list * * @param element: the element to be added */ public void addLast(T element); /** * Adds the specified element to the list after the existing element * * @param existing: the element that is in the list already * @param element: the element to be added * @throws ElementNotFoundException if existing isn't in the list */ public void addAfter(T existing, T element) throws ElementNotFoundException, EmptyCollectionException;
  • 3. /** * Removes and returns the specified element * * @return the element specified * @throws EmptyCollectionException * @throws ElementNotFoundException */ public T remove(T element) throws EmptyCollectionException, ElementNotFoundException; /** * Removes and returns the first element * * @return the first element in the list * @throws EmptyCollectionException */ public T removeFirst() throws EmptyCollectionException; /** * Removes and returns the last element * * @return the last element in the list * @throws EmptyCollectionException */ public T removeLast() throws EmptyCollectionException; /** * Returns (without removing) the first element in the list * * @return element at the beginning of the list * @throws EmptyCollectionException */ public T first() throws EmptyCollectionException; /** * Returns (without removing) the last element in the list * * @return element at the end of the list * @throws EmptyCollectionException */ public T last() throws EmptyCollectionException; /** * Return whether the list contains the given element. * * @param element * @return * @throws EmptyCollectionException
  • 4. */ public boolean contains(T element) throws EmptyCollectionException; /** * Returns the index of the given element. * * @param element * @return the index of the element, or -1 if not found */ public int indexOf(T element); /** * Return the element at the given index of a list. * * @param element * @return * @throws EmptyCollectionException */ public T get(int index) throws EmptyCollectionException, InvalidArgumentException; /** * Set the at the given index of a list. * * @param element * @return * @throws EmptyCollectionException */ public void set(int index, T element) throws EmptyCollectionException, InvalidArgumentException; } *********************************************** /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package ADTs; /** * An interface for an AbstractDataType * Specific ADT interfaces will extend this * For use in Data Structures & Algorithms * * * @author unknown */ public interface CollectionADT<T> {
  • 5. /** * Returns true if the collection contains no elements * * @return true if the collection is empty */ public boolean isEmpty(); /** * Returns the number of elements in the collection * * @return the number of elements as an int */ public int size(); /** * Returns a string representation of the collection * * @return a string representation of the collection */ @Override public String toString(); } ********************************** Project must compile (otherwise no grade) (1) JavaDoc for DataStructures.ArrayStack class (2) Tests passing for DataStructures.ArrayStack class