Unit tests the Queue data type. @param args the command-line arguments
(String[] args)
| 168 | * @param args the command-line arguments |
| 169 | */ |
| 170 | public static void main(String[] args) { |
| 171 | Queue<String> queue = new Queue<String>(); |
| 172 | while (!StdIn.isEmpty()) { |
| 173 | String item = StdIn.readString(); |
| 174 | if (!item.equals("-")) |
| 175 | queue.enqueue(item); |
| 176 | else if (!queue.isEmpty()) |
| 177 | StdOut.print(queue.dequeue() + " "); |
| 178 | } |
| 179 | StdOut.println("(" + queue.size() + " left on queue)"); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | /****************************************************************************** |