/**
 * Jatkoa Rectangle-luokalle:
 * - Oliot metodin parametrina ja palautusarvona
 * - Kopioiden luonti olioista
 * - Periytyminen, rajapintaluokat ja abstraktit luokat
 */
public class UusiRectangle extends Shape
{
	int width = 5;
	int height;

	static int nbrRect = 0;

	public UusiRectangle()
	{
		super();
		width = 10;
		nbrRect++;
	}

	public UusiRectangle(int w, int height)
	{
		this();
		width = w;
		this.height = height;
	}

	public UusiRectangle(UusiRectangle r)
	{
		x = r.x;
		y = r.y;
		width = r.width;
		height = r.height;
	}

	public UusiRectangle cloneRect()
	{
		return new UusiRectangle(this);
	}

	public int getWidth()
	{
		return width;
	}

	static int getNbrRect()
	{
		return nbrRect;
	}

	public void draw() {}

	public String toString()
	{
		return super.toString() + ", width: " + width + ", height: " + height;
	}

	public static void main(String[] args)
	{
		int i = 50;

		System.out.println("i: " + i);

		UusiRectangle r1 = new UusiRectangle();
		UusiRectangle r2 = new UusiRectangle(i, 60);
		UusiRectangle r3 = new UusiRectangle(r2);

		System.out.println("i: " + i);
		System.out.println(r1);
		System.out.println(r2);
		System.out.println(r3);
		r2.getXLocation();
		UusiRectangle r4 = r1.cloneRect();
		System.out.println(r4);
		String s = "" + r1 + r2 + r3 + r4;
		System.out.println(s);
		System.out.println(UusiRectangle.getNbrRect());
	}
}

abstract class Shape implements ShapeInterface
{
	int x;
	int y;

	public Shape()
	{
		x = 15;
		y = 24;
	}

	public Shape(int x, int y)
	{
		this.x = x;
		this.y = y;
	}

	public int getXLocation()
	{
		return x;
	}

	public void setXLocation(int x)
	{
		this.x = x;
	}

	public String toString()
	{
		return "x: " + x + ", y: " + y;
	}

}

interface ShapeInterface
{
	public int getXLocation();
	public void setXLocation(int x);
	public void draw();
}



