import java.awt.*;

class XORCanvas extends Canvas {
        // Draw two overlapping rectangles.
    public void paint(Graphics g){
        Dimension size = getSize();

        // Define the width and height of the shapes.
        final int shapeWidth = size.width/4, shapeHeight = size.height/2;

        // The x and y shift for the second shape.
        final int xShift = shapeWidth/2, yShift = 0;
        // Evenly space between the sides and top.
        final int xPos = (size.width-(shapeWidth+xShift))/2,
                  yPos = (size.height-(shapeHeight+yShift))/2;

        // Fill the first rectangle.
        g.setColor(Color.red);
        g.fillRect(xPos,yPos,shapeWidth,shapeHeight);
        g.setXORMode(Color.green);
        // Fill the second rectangle.
        g.fillRect(xPos+xShift,yPos+yShift,shapeWidth,shapeHeight);
    }
}
