Package Painting

Class ShapeStack

java.lang.Object
Painting.ShapeStack

public class ShapeStack
extends java.lang.Object
implement a stack of shapes using ArrayList
Author:
Itay Finci
  • Field Summary

    Fields 
    Modifier and Type Field Description
    private java.util.ArrayList<MyShape> stack  
  • Constructor Summary

    Constructors 
    Constructor Description
    ShapeStack()
    make empty stack
  • Method Summary

    Modifier and Type Method Description
    void clear()
    remove all of the shapes from the stack
    void drawStack​(java.awt.Graphics g)
    draw the shapes from the stack
    void insert​(MyShape shape)
    inset shape to the end of the list
    MyShape pop()
    remove the last shape (the most recently added)

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ShapeStack

      public ShapeStack()
      make empty stack
  • Method Details

    • insert

      public void insert​(MyShape shape)
      inset shape to the end of the list
      Parameters:
      shape - the shape to be inserted
    • pop

      public MyShape pop()
      remove the last shape (the most recently added)
      Returns:
      the shape that was removed
    • clear

      public void clear()
      remove all of the shapes from the stack
    • drawStack

      public void drawStack​(java.awt.Graphics g)
      draw the shapes from the stack
      Parameters:
      g - the graphics manager