/*
 * @(#)ShapeContainerContext.java	1.0 11-Apr-07
 *
 * IIT Bombay, 
 * Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 License.
 */
package classes.container;

import interfaces.IShape;
import interfaces.IShapeContainerState;

/**
 * Performs the operations based on the state of the container
 *
 * @author  Prathab, Mukesh
 * @version 1.0, 22-Mar-07
 */
public class ShapeContainerContext {
	public ShapeContainer shapeContainer;
	public IShapeContainerState shapeContainerState;
	public int shapeObjectsCount= 0;
	
	/**
	 * Initialize with the container and current state object
	 * @param shapeContainer shape container on which operations are performed
	 * @param shapeContainerState current state of the shape container
	 */
	public ShapeContainerContext(ShapeContainer shapeContainer, IShapeContainerState shapeContainerState) {
		this.shapeContainer = shapeContainer;
		this.shapeContainerState = shapeContainerState;
	}
	
	/**
	 * Adds the given shape to the container based on the state of the coantiner.  
	 * @param shape the shape to be added
	 */
	public boolean addShape(IShape shape) {
		return shapeContainerState.addShape(this, shape);
	}
	
	/**
	 * Removes the given shape from the container based on the state of the coantiner.  
	 * @param shape the shape to be removed
	 */
	public boolean removeShape(IShape shape) {
		return shapeContainerState.removeShape(this,shape);
	}

}
