fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections; // For old-style ArrayList.
  4.  
  5. class Example
  6. {
  7. public static void Main()
  8. {
  9. Queue <string> bookCollection = new Queue<string>();
  10.  
  11. bookCollection.Enqueue ("Rogue Lawyer");
  12. bookCollection.Enqueue ("The Bazaar of Bad Dreams: Stories");
  13. bookCollection.Enqueue ("The Crossing");
  14. bookCollection.Enqueue ("The Magic Strings of Frankie Presto: A Novel");
  15. bookCollection.Enqueue ("See Me");
  16.  
  17. // Print the books in my Wishlist
  18. Console.WriteLine("Here are the current books in my Amazon Wishlist (9/15/2015)");
  19. foreach (string books in bookCollection)
  20. {
  21. Console.WriteLine(books);
  22. }
  23.  
  24. // I asked my sales rep to send out the books monthly, so my wife doesn't kill me!
  25. // When the first book is ship my sales rep will remove it from my Wishlist
  26. // Note that Rogue Lawyer was at the top of the Wishlist, so he deletes it
  27. bookCollection.Dequeue ();
  28. bookCollection.Dequeue ();
  29. // and my new Wishlist will look like this
  30.  
  31. Console.WriteLine("\nMy Amazon Wishlist after recieving 2 books on (10/17/2015)");
  32. foreach (string books in bookCollection)
  33. {
  34. Console.WriteLine(books);
  35. }
  36.  
  37. // Print number of current books in my Amazon Wishlist
  38. Console.Write("\nNumber of books in the Amazon Wishlist: " + bookCollection.Count);
  39. Console.Write("\n\n");
  40.  
  41. // I just add 3 more books to my wishlist. I can't stop reading!!!!
  42. bookCollection.Enqueue ("Crimson Shore (Agent Pendergast series)");
  43. bookCollection.Enqueue ("The Japanese Lover: A Novel");
  44. bookCollection.Enqueue ("Career of Evil (Cormoran Strike Novels)");
  45.  
  46. // Print the books in my Wishlist
  47. Console.WriteLine("\nHere are the current books in my Amazon Wishlist, I can't stop myself! (11/15/2015)");
  48. foreach (string books in bookCollection)
  49. {
  50. Console.WriteLine(books);
  51. }
  52.  
  53. // Print number of current books in my Amazon Wishlist
  54. Console.Write("\nNumber of books in the Amazon Wishlist: " + bookCollection.Count);
  55.  
  56. Console.Write("\n\n");
  57. Console.Write("Part II - Bring the stacks! \n");
  58. Stack bookStack = new Stack();
  59. bookStack.Push ("Rogue Lawyer");
  60. bookStack.Push ("The Bazaar of Bad Dreams: Stories");
  61. bookStack.Push ("The Crossing (Bosch)");
  62. bookStack.Push ("The Magic Strings of Frankie Presto: A Novel");
  63. bookStack.Push ("See Me");
  64.  
  65. Console.WriteLine("Tim's Top 5 books for this weekend ...\n");
  66.  
  67. // print all of the books needed
  68. foreach(string book in bookStack) {
  69. Console.WriteLine(book);
  70. } // foreach
  71.  
  72. // adding in 2 more books
  73. bookStack.Push ("Crimson Shore (Agent Pendergast series)");
  74. bookStack.Push ("The Japanese Lover: A Novel");
  75.  
  76. Console.WriteLine("\n\nTim added 2 more books, totalling 7 books ...\n");
  77.  
  78. // print all of the books needed
  79. foreach(string book in bookStack) {
  80. Console.WriteLine(book);
  81. } // foreach
  82.  
  83.  
  84. Console.WriteLine("\n\nPopping the 3 books from the Stack ...\n"); // skip a few lines
  85.  
  86. while(bookStack.Count > 4) {
  87. string book = (string) bookStack.Pop ();
  88. Console.WriteLine("Popping {0}", book );
  89. } // while
  90.  
  91.  
  92. Console.WriteLine("\n\nTim's 4 books needed for this weekend ...\n");
  93.  
  94. // print all of the books needed
  95. foreach(string book in bookStack) {
  96. Console.WriteLine(book);
  97. } // foreach
  98. }
  99. }
  100.  
Success #stdin #stdout 0.06s 24040KB
stdin
Standard input is empty
stdout
Here are the current books in my Amazon Wishlist (9/15/2015)
Rogue Lawyer
The Bazaar of Bad Dreams: Stories
The Crossing
The Magic Strings of Frankie Presto: A Novel
See Me

My Amazon Wishlist after recieving 2 books on (10/17/2015)
The Crossing
The Magic Strings of Frankie Presto: A Novel
See Me

Number of books in the Amazon Wishlist: 3


Here are the current books in my Amazon Wishlist, I can't stop myself! (11/15/2015)
The Crossing
The Magic Strings of Frankie Presto: A Novel
See Me
Crimson Shore (Agent Pendergast series)
The Japanese Lover: A Novel
Career of Evil (Cormoran Strike Novels)

Number of books in the Amazon Wishlist: 6

Part II - Bring the stacks! 
Tim's Top 5 books for this weekend ...

See Me
The Magic Strings of Frankie Presto: A Novel
The Crossing (Bosch)
The Bazaar of Bad Dreams: Stories
Rogue Lawyer


Tim added 2 more books, totalling 7 books ...

The Japanese Lover: A Novel
Crimson Shore (Agent Pendergast series)
See Me
The Magic Strings of Frankie Presto: A Novel
The Crossing (Bosch)
The Bazaar of Bad Dreams: Stories
Rogue Lawyer


Popping the 3 books from the Stack ...

Popping The Japanese Lover: A Novel
Popping Crimson Shore (Agent Pendergast series)
Popping See Me


Tim's 4 books needed for this weekend ...

The Magic Strings of Frankie Presto: A Novel
The Crossing (Bosch)
The Bazaar of Bad Dreams: Stories
Rogue Lawyer