/** Boston University, Department of Computer Science CS 112, Spring 2011 Lab 03: Linked data structures Teaching Fellow: Diane H. Theriault, deht@cs.bu.edu */ import java.util.*; public class LinkedQueue{ class Node{ Node(int iValue) { mValue = iValue; mNext = null; } public int mValue; public Node mNext; } protected Node mHead; protected Node mTail; LinkedQueue() { mHead = null; } void enqueue(int iValue) { if(mHead == null) { mHead = new Node(iValue); mTail = mHead; return; } else { mTail.mNext = new Node(iValue); mTail = mTail.mNext; } } void print() { Node current = mHead; while(current != null) { System.out.print(current.mValue); if(current != mTail) { System.out.print(", "); } current = current.mNext; } System.out.println(); } }