Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement a queue using a LinkedList object to store the queue elements /* * To change this license header, choose License Headers in Project Properties.

Implement a queue using a LinkedList object to store the queue elements

/* * 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 jsjf;

import jsjf.exceptions.*; import java.util.LinkedList;

/** * A linked list implementation of a queue. * * Solution to Programming Project 6.3. * * @author Lewis and Chase * @version 4.0 */ public class LinkedListQueue implements QueueADT { LinkedList queue;

/** * Creates an empty queue. */ public LinkedListQueue() { queue = new LinkedList(); }

/** * Adds the specified element to the end of this queue. * @param element the element to be added */ public void enqueue(T element) { // To be completed as a Programming Project }

/** * Removes the element at the front of this queue and returns a * reference to it. * @return the element at the front of this queue * @throws EmptyCollectionException if the queue is empty */ public T dequeue() throws EmptyCollectionException { // To be completed as a Programming Project } /** * Returns a reference to the element at the front of this queue. * The element is not removed from the queue. * @return a reference to the first element in this queue * @throws EmptyCollectionsException if the queue is empty */ public T first() throws EmptyCollectionException { // To be completed as a Programming Project }

/** * Returns true if this queue is empty and false otherwise. * @return true if this queue is empty */ public boolean isEmpty() { // To be completed as a Programming Project } /** * Returns the number of elements currently in this queue. * @return the number of elements in the queue */ public int size() { // To be completed as a Programming Project }

/** * Returns a string representation of this queue. * @return the string representation of the queue */ public String toString() { // To be completed as a Programming Project } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions