Course Solutions Uncategorized (Solved) : Convert Linkedqueue Generic Class Store Objects Type Use Linkedqueue Class Provided Assign Q35420469 . . . .

(Solved) : Convert Linkedqueue Generic Class Store Objects Type Use Linkedqueue Class Provided Assign Q35420469 . . . .

 

Convert LinkedQueue into a generic class that can store objectsof any type. Use LinkedQueue class provided with the assignmentbelow.

************************************
public class LinkedQueue
{
private class Node
{
String value;
Node next;
Node(String val, Node n)
{
value = val;
next = n;
}   
}

private Node front = null;
private Node rear = null;   
  
public void enqueue(String s)
{
if (rear != null)
{
rear.next = new Node(s, null);
rear = rear.next;
}
else
{
rear = new Node(s, null);
front = rear;
}
}

public boolean empty()
{
return front == null;
}
  
public String peek()
{
if (empty())
throw new EmptyQueueException();
else
return front.value;
}

public String dequeue()
{
if (empty())
throw new EmptyQueueException();
else
{
String value = front.value;
front = front.next;
if (front == null) rear = null;
return value;
}
}

public String toString()
{
StringBuilder sBuilder = new StringBuilder();

// Walk down the list and append

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post