Create an implementation of Stack interface provided - For the implementation create a tester to verify the implementation of that data structure performs as expected Get on the bus – Stack (lifo) - Implement the provided Stack interface ( fill out the implementation shell) - Put your implementation through its paces by exercising each of the methods in a test harness

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Simple stack implementation

please help (looks like a lot but actually isnt, everything is already set up for you below to make it even easier)

help in any part you can, please be clear, thank you

Given an interface for Stack
- Without using the java collections interface (ie do not import java.util.List,
LinkedList, Stack, Queue...)
- Create an implementation of Stack interface provided
- For the implementation create a tester to verify the implementation of that
data structure performs as expected

Get on the bus – Stack (lifo)
- Implement the provided Stack interface ( fill out the implementation shell)
- Put your implementation through its paces by exercising each of the methods in
a test harness
- Add to your ‘BusClient’ the following functionality using your Stack
-
o Create (push) 6 riders by name
§ Iterate over the stack, print all riders
o Peek at the stack / print the result
o Remove (pop) the top of the stack
§ Iterate over the stack, print all riders
o Peek at the stack / print the result
o Add two more riders to the stack
o Peek at the stack & print the result
o Remove all riders from the stack
o Verify the stack is now empty ( print that result )

4 CLASSES TO BEGIN WITH BELOW (edit these classes to fulfill the easy requirements above)

import linkedList.LinkedList;
import linkedList.LinkedListImpl;
import queue.Queue;
import queue.QueueImpl;
import stack.Stack;
import stack.StackImpl;

public class BusClient {

    public static void main(String[] args) {
        // create implementation, then                 
        System.out.println("-----S T A C K  T E S T------");             

        //StackRunTestMethod...
        
         }

}

----------

package stack;

public interface Stack {
 
    public void push(String s);
    public String pop();
    public Boolean isEmpty();
    public Boolean isFull();
    public int size();
    public String peek();
    
    public void setCapacity(int size);
    public void display();
}

----------

package stack; 

public class StackImpl implements Stack {

    String[] arr = new String[5];
    int index = 0;
            
    
    @Override
    public void push(String s) {


        if (isFull())   {  
            System.out.println("Sorry, no room left..");
            return;
        }

        //uh
        //move each element in array to pos + 1

        for (int i = index; i > 0; i--) {
            arr[i] = arr[i - 1];
        }
         
        //after all moved, add new element to 0th
        arr[0] =s;
        
        index++;
        
    }

    @Override
    public String pop() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Boolean isEmpty() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Boolean isFull() {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public int size() {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public String peek() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void setCapacity(int size) {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void display() {
        // TODO Auto-generated method stub
        
    }

}

----------

package stack;

public class StackTester {

    public static void main(String[] args) {
 
        Stack s = new StackImpl();
        runTests(s);
    }
    
    public static void runTests(Stack stack) {
         
        stack.push("silly");
        stack.push("sally");
        stack.push("sells");
        stack.push("used cars");

        //check this is used cars
        stack.pop();
        
        
        //
        
    }

}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY