

import java.awt.Color;
import java.awt.Graphics;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;

class RectangleObj 
{
		int x, y;
		int width, height;
		Color color;
		boolean selected;
		
		int x1, y1, x2, y2;
	
		public RectangleObj()
		{
			
		}
		
		/*public RectangleObj(int x, int y, int w, int h, Color c )
		{
			this.x = x;
			this.y = y;
			this.width = w;
			this.height = h;
			this.color = c;
			this.selected = false;
		}*/
		
		public RectangleObj(int x1, int y1, int x2, int y2, Color c )
		{
			this.x1 = x1;
			this.y1 = y1;
			this.x2 = x2;
			this.y2 = y2;
			this.color = c;
			this.selected = false;
			//width = getWidth();
			//height = getHeight();
		}
		
		
		public int getUpperLeftX()
	    {
	        return Math.min( x1, x2);
	    }
	    
	    public int getUpperLeftY()
	    {
	        return Math.min( y1, y2 );
	    }
	    
	   
	    public int CalcWidth()
	    {
	    	width = Math.abs(x1 - x2);
	        return width;
	    }
	    
	    public int CalcHeight()
	    {
	    	height = Math.abs(y1 - y2 );
	        return height;
	    }
	    
	    public int getWidth()
	    {
	        return width;
	    }
	    
	    public int getHeight()
	    {
	        return height;
	    }
	    
	    
	    

	    public void setX1(int x1)
	    {
	        this.x1=x1;
	    }  
	    
	    public int getX1()
	    {
	        return x1;
	    }
		    
	    public void setY1(int y1)
	    {
	        this.y1=y1;
	    }   
	    
	    public int getY1()
	    {
	        return y1;
	    }
	    
		    
	    public void setX2(int x2)
	    {
	        this.x2=x2;
	    }   
	    
	    public int getX2()
	    {
	    	return x2;
	    }
		    
	    public void setY2(int y2)
	    {
	        this.y2=y2;
	    }   
		 
	    public int getY2()
	    {
	    	return y2;
	    }
	    
	    
	    public void setSelected(boolean select)
	    {
			selected = select;
		}

	    public void setUnSelected(boolean state) 
	    { 
	    	selected = state; 
    	}
	    
		public boolean getsetSelected()
		{
			return selected;
		}
		
		public void toggleSelected() 
		{ 
			selected = !selected; 
		}
		
		public boolean isSelected() 
		{ 
			return selected; 
		}

		public void setWidth(int w) 
		{
			width = w;
		}

		public void setHeight(int h) 
		{
			height = h;
		}

		public void saveTo(PrintWriter aFile) 
		{
		        aFile.println( getX1() );
		        aFile.println( getY1() );
		        aFile.println( getX2() );
		        aFile.println( getY2() );
		        aFile.println( getWidth() );
		        aFile.println( getHeight() );
		        aFile.println(selected);
		}
		
	    public static RectangleObj loadFrom(BufferedReader aFile) throws IOException 
	    {
	        RectangleObj   aRect = new RectangleObj();
	        aRect.setX1( Integer.parseInt(aFile.readLine()) );
	        aRect.setY1( Integer.parseInt(aFile.readLine()) );
	        aRect.setX2( Integer.parseInt(aFile.readLine()) );
	        aRect.setY2( Integer.parseInt(aFile.readLine()) );
	        aRect.setWidth( Integer.parseInt(aFile.readLine()) );
	        aRect.setHeight( Integer.parseInt(aFile.readLine()) );
	        aRect.setSelected(Boolean.valueOf(aFile.readLine()).booleanValue());
	        return aRect;
	    }
		
}