コード例 #1
0
        // Adds a new stack entry to stackEntries
        public void add(int input)
        {
            StackEntryDrawing inputStackEntry = new StackEntryDrawing(width, height, x, y, input);

            this.stackEntries.push(inputStackEntry);
            y -= height;
        }
コード例 #2
0
        public StackDrawing(int x, int startY, int width, int height, LinkedStack <int> inputs)
        {
            this.y            = startY - height;
            this.stackEntries = new LinkedStack <StackEntryDrawing>();

            // Populate stackEntries. The first entry is the last element of inputs.
            // This is because the stack is drawn from the base -- as a result, we must reverse the order of inputs
            // when drawing the image of the stack itself.
            while (!inputs.isEmpty())
            {
                StackEntryDrawing currEntry = new StackEntryDrawing(width, height, x, y, inputs.First.Value);
                inputs.RemoveFirst();
                this.stackEntries.AddFirst(currEntry);
                y -= height;
            }

            this.x      = x;
            this.width  = width;
            this.height = height;
        }