static void Main() { SimpleQueue bigQ = new SimpleQueue(100); SimpleQueue smallQ = new SimpleQueue(4); char ch; int i; Console.WriteLine("Using bigQ to store the alphabet."); for (i = 0; i < 26; i++) { bigQ.Put((char)('A' + i)); } Console.Write("Contents of bigQ: "); for (i = 0; i < 26; i++) { ch = bigQ.Get(); if (ch != (char)0) { Console.Write(ch); } } Console.WriteLine("\n"); Console.WriteLine("Using smallQ to generate errors"); for (i = 0; i < 5; i++) { Console.Write("Attempting to store " + (char)('Z' - i)); smallQ.Put((char)('Z' - i)); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine("Contents of smallQ: "); for (i = 0; i < 5; i++) { ch = smallQ.Get(); if (ch != (char)0) { Console.Write(ch); } } }
static void Main() { SimpleQueue q1 = new SimpleQueue(10); char[] name = { 'T', 'o', 'm' }; SimpleQueue q2 = new SimpleQueue(name); char ch; int i; for (i = 0; i < 10; i++) { q1.Put((char)('A' + i)); } SimpleQueue q3 = new SimpleQueue(q1); Console.Write("Contests of q1: "); for (i = 0; i < 10; i++) { ch = q1.Get(); Console.Write(ch); } Console.WriteLine("\n"); Console.Write("Contests of q2: "); for (i = 0; i < 3; i++) { ch = q2.Get(); Console.Write(ch); } Console.WriteLine("\n"); Console.Write("Contents of q3: "); for (i = 0; i < 10; i++) { ch = q3.Get(); Console.Write(ch); } }