package rectangle;

public class Square {

	private Rectangle delegate;

	public Square(int size, int x, int y) {
		delegate = new Rectangle(size, size, x, y);
	}

	public int size() {
		return delegate.height();
	}

	public void setSize(int s) {
		delegate.setHeight(s);
		delegate.setWidth(s);
	}

	public int x() {
		return delegate.x();
	}

	public int y() {
		return delegate.y();
	}

	public void moveTo(int x, int y) {
		System.out.println("square moves");
		delegate.moveTo(x, y);
	}

	public int perimeter() {
		return delegate.perimeter();
	}

	public int surface() {
		return delegate.surface();
	}

	private Rectangle rectView = null;
	
	public Rectangle rectangle() {
		if (rectView == null)
rectView = new InternalRectangle(size(), x(), y());
		return rectView;
	}

	private class InternalRectangle extends Rectangle {

		public InternalRectangle(int size, int x, int y) {
			super(size, size, x, y);
		}

		public void setHeight(int h) {
			throw new UnsupportedOperationException();
		}

		public void setWidth(int w) {
			throw new UnsupportedOperationException();
		}
		
		
	}
}
