Advertisement
jtentor

DemoQueue4 - DemoQueue4.java

May 17th, 2020
606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. public class DemoQueue4 {
  4.     public static void main(String[] args) {
  5.         System.out.print("Demo Queue - versión librería estándar - Caso Ejemplo b)\n");
  6.         SpecialQueue<Integer> queue1 = new SpecialQueue<Integer>();
  7.  
  8.         Random random = new Random();
  9.  
  10.         int number;
  11.         System.out.print("Enqueuing...\n");
  12.         for (int c = 0; c < 10; ++c) {
  13.             queue1.add(number = random.nextInt(11));
  14.             System.out.printf("%d ", number);
  15.         }
  16.         System.out.print("\n");
  17.  
  18.         System.out.print("Joining with same queue...\n");
  19.         SpecialQueue<Integer> queue2 = queue1.join(queue1);
  20.  
  21.  
  22.         System.out.print("Dequeuing...\n");
  23.         while (queue1.size() > 0) {
  24.             System.out.printf("%d ", queue1.remove());
  25.         }
  26.         System.out.print("\n");
  27.         System.out.print("Dequeuing joined queue...\n");
  28.         while (queue2.size() > 0) {
  29.             System.out.printf("%d ", queue2.remove());
  30.         }
  31.         System.out.print("\n");
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement