Giter Club home page Giter Club logo

java-stack's Introduction

Stack

Instructions

A "stack" is an abstract data type. It is a LIFO construct: Last In, First Out. Think of a stack of plates in a dining hall or restaurant's plate dispenser. The first plate gets a bunch of plates put on top of it. The last plate you put on the stack of plates is the first one you could remove.

  • Make a class called "Stack" and give it this LIFO functionality. Our Stack class's storage will be an Array with a maximum of 1000 elements of type string. You'll want to make methods
  • Print - print the items in the order they were added to the stack. Should be in the form of [‘item1’, ‘item2’]
  • Pop - Remove the last item from the stack and return the item
  • Push - Put the item on top of the stack
  • numOfItems - No items in on the stack, return the message “There are no items in your Stack, otherwise, return the number of items.

After creating the classes, have the program do the following

  • Make a new stack
  • Report number of items on the stack
  • Push first
  • Push second
  • Push third
  • Report number of items on the stack
  • Print the stack
  • Pop the stack
  • Print the stack
  • Pop the stack
  • Print the stack
  • Pop the stack
  • Print the stack
  • Report number of items on the stack

Your output should look like this:

There are no items in your Stack.

3

[ 'first', 'second', 'third' ]

[ 'first', 'second' ]

[ 'first' ]

[]

There are no items in your Stack.

java-stack's People

Contributors

jrmmba8314 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.