using System;
using System.Collections.Generic;
using System.Collections; // For old-style ArrayList.
class Example
{
public static void Main()
{
Queue <string> bookCollection = new Queue<string>();
bookCollection.Enqueue ("Rogue Lawyer");
bookCollection.Enqueue ("The Bazaar of Bad Dreams: Stories");
bookCollection.Enqueue ("The Crossing");
bookCollection.Enqueue ("The Magic Strings of Frankie Presto: A Novel");
bookCollection.Enqueue ("See Me");
// Print the books in my Wishlist
Console.WriteLine("Here are the current books in my Amazon Wishlist (9/15/2015)");
foreach (string books in bookCollection)
{
Console.WriteLine(books);
}
// I asked my sales rep to send out the books monthly, so my wife doesn't kill me!
// When the first book is ship my sales rep will remove it from my Wishlist
// Note that Rogue Lawyer was at the top of the Wishlist, so he deletes it
bookCollection.Dequeue ();
bookCollection.Dequeue ();
// and my new Wishlist will look like this
Console.WriteLine("\nMy Amazon Wishlist after recieving 2 books on (10/17/2015)");
foreach (string books in bookCollection)
{
Console.WriteLine(books);
}
// Print number of current books in my Amazon Wishlist
Console.Write("\nNumber of books in the Amazon Wishlist: " + bookCollection.Count);
Console.Write("\n\n");
// I just add 3 more books to my wishlist. I can't stop reading!!!!
bookCollection.Enqueue ("Crimson Shore (Agent Pendergast series)");
bookCollection.Enqueue ("The Japanese Lover: A Novel");
bookCollection.Enqueue ("Career of Evil (Cormoran Strike Novels)");
// Print the books in my Wishlist
Console.WriteLine("\nHere are the current books in my Amazon Wishlist, I can't stop myself! (11/15/2015)");
foreach (string books in bookCollection)
{
Console.WriteLine(books);
}
// Print number of current books in my Amazon Wishlist
Console.Write("\nNumber of books in the Amazon Wishlist: " + bookCollection.Count);
Console.Write("\n\n");
Console.Write("Part II - Bring the stacks! \n");
Stack bookStack = new Stack();
bookStack.Push ("Rogue Lawyer");
bookStack.Push ("The Bazaar of Bad Dreams: Stories");
bookStack.Push ("The Crossing (Bosch)");
bookStack.Push ("The Magic Strings of Frankie Presto: A Novel");
bookStack.Push ("See Me");
Console.WriteLine("Tim's Top 5 books for this weekend ...\n");
// print all of the books needed
foreach(string book in bookStack) {
Console.WriteLine(book);
} // foreach
// adding in 2 more books
bookStack.Push ("Crimson Shore (Agent Pendergast series)");
bookStack.Push ("The Japanese Lover: A Novel");
Console.WriteLine("\n\nTim added 2 more books, totalling 7 books ...\n");
// print all of the books needed
foreach(string book in bookStack) {
Console.WriteLine(book);
} // foreach
Console.WriteLine("\n\nPopping the 3 books from the Stack ...\n"); // skip a few lines
while(bookStack.Count > 4) {
string book = (string) bookStack.Pop ();
Console.WriteLine("Popping {0}", book );
} // while
Console.WriteLine("\n\nTim's 4 books needed for this weekend ...\n");
// print all of the books needed
foreach(string book in bookStack) {
Console.WriteLine(book);
} // foreach
}
}