import extensions; class Queue { T[] theArray; int theTop; int theTale; constructor() { theArray := new T[](8); theTop := 0; theTale := 0; } bool empty() = theTop == theTale; push(T object) { if (theTale > theArray.Length) { auto newArray := class Array.allocate(theTale); class Array.copy(newArray, theArray, 0, theArray.Length); theArray := newArray }; theArray[theTale] := object; theTale += 1 } T pop() { if (theTale == theTop) { InvalidOperationException.new("Queue is empty").raise() }; T item := theArray[theTop]; theTop += 1; ^ item } } public Program() { Queue q := new Queue(); q.push(1); q.push(2); q.push(3); Console.printLine(q.pop()); Console.printLine(q.pop()); Console.printLine(q.pop()); Console.printLine("a queue is ", q.empty().iif("empty","not empty")); Console.print("Trying to pop:"); try { q.pop() } catch(Exception e) { Console.printLine(e.Message) } }