// Assuming Customer class is defined
// LinkedQueue.java : Java program to create a Queue using
LinkedList
import java.util.NoSuchElementException;
public class LinkedQueue {
// inner class Node representing the Node of the
LinkedQueue where data contains Customer and next is the Node to
the next Customer
private class Node
{
Customer data;
Node next;
public Node(Customer inData)
{
data =
inData;
next =
null;
}
public Customer toString()
{
return(data.toString());
}
}
private Node head; // start of queue
private Node tail; // end of queue
// constructor to create an empty Queue
public LinkedQueue()
{
head = null;
tail = null;
}
// method to insert the Customer at the end of the
queue
public void enqueue(Customer data)
{
if(data != null)
{
Node node = new
Node(data);
if(isEmpty())
{
head = node;
tail = node;
}else
{
tail.next =node;
tail = node;
}
}
}
// method to remove and return the Customer at the
front of the Queue
public Customer dequeue() throws
NoSuchElementException
{
if(!isEmpty())
{
Customer item =
head.data;
head =
head.next;
if(head ==
null)
tail = null;
return
item;
}
throw new
NoSuchElementException();
}
// method to return the Customer at the front of the
queue
public Customer getFront() throws
NoSuchElementException
{
if(!isEmpty())
{
return
head.data;
}
throw new
NoSuchElementException();
}
// method to return the String representation of the
queue
public String toString()
{
String queueStr = "";
Node curr = head;
while(curr != null)
{
queueStr +=
(curr.toString()+"\n");
curr =
curr.next;
}
return queueStr;
}
// method to return true if the queue is empty else
false
public boolean isEmpty(){return (head ==
null);}
}
//end of LinkedQueue.java
USE JAVA PROGRAMMING LANGUAGE See all photos + Add to a ♡ Search Edit & Create...
Queues This programming exercise introduces the Queue data structure. The students must create all the necessary methods for the queue and use the queue in a Java program. Step 1 - Create a new project in Netbeans Use the following naming convention: “Module4_Lastname_Assignment1”. Step 2 - Build a solution You have been asked to create a customer service program for a new phone store that will be opening soon. Since this company anticipates being the agent for a rising new...
Needs Help with Java programming language For this assignment, you need to write a simulation program to determine the average waiting time at a grocery store checkout while varying the number of customers and the number of checkout lanes. Classes needed: SortedLinked List: Implement a generic sorted singly-linked list which contains all of the elements included in the unsorted linked list developed in class, but modifies it in the following way: • delete the addfirst, addlast, and add(index) methods and...
Please try to write the code with Project 1,2 and 3 in mind. And use java language, thank you very much. Create an Edit Menu in your GUI Add a second menu to the GUI called Edit which will have one menu item called Search. Clicking on search should prompt the user using a JOptionPane input dialog to enter a car make. The GUI should then display only cars of that make. You will need to write a second menu...