Coder Social home page Coder Social logo

java-mod-2-queue-lab's Introduction

Queue Lab

Learning Goals

  • Use a queue to keep track of information

Instructions

Let's create a lightweight, simplified, restaurant reservation system:

  1. Our restaurant has 2 tables
  2. In an input loop, ask the user if they want to check someone in or check someone out
  3. If they want to check someone in, check if a table is available.
    1. If a table is available, check them in
    2. If a table is not available, put them on a waiting list
  4. If they want to check someone out:
    1. Free one of the table that is taken
    2. Immediately assign the table to the next person on the waiting list

Hints:

  1. You can use an array, a list, a map or a queue for your tables - each data structure has pros and cons, but you can make each one work for the list of tables
  2. Use a queue for your wait list, as that's the most natural data structure for this type of scenario
  3. You may want to use a class named Restaurant that holds both your table list and your waitlist
  4. Your Restaurant class will have a method you might call checkin and a method called checkout that will be responsible for implementing the logic we described above

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.