Advertisement
jtentor

DemoQueue3 - DemoQueue3.java

May 17th, 2020
519
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Random;
  2.  
  3. public class DemoQueue3 {
  4.     public static void main(String[] args) {
  5.         System.out.print("Demo Queue - versión genérica - 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.         {
  14.             queue1.add(number = random.nextInt(11));
  15.             System.out.printf("%d ", number);
  16.         }
  17.         System.out.print("\n");
  18.  
  19.         System.out.print("Joing with the same queue...\n");
  20.         SpecialQueue<Integer> queue2 = queue1.join(queue1);
  21.  
  22.  
  23.         System.out.print("Dequeuing...\n");
  24.         while (queue1.size() > 0) {
  25.             System.out.printf("%d ", queue1.remove());
  26.         }
  27.         System.out.print("\n");
  28.         System.out.print("Dequeuing joined queue...\n");
  29.         while (queue2.size() > 0) {
  30.             System.out.printf("%d ", queue2.remove());
  31.         }
  32.         System.out.print("\n");
  33.     }
  34. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement