package csa120.shape; import java.awt.Graphics2D; import java.awt.BasicStroke; /** * A Square is a subclass of {@link Rectangle}. To ensure that the * height and width remain the same, any change to one of those values * will automatically force a change of the other. * * @author (Michael H. Goldwasser) * @version (23 January 2004) */ public class Square extends Rectangle { /** * Constructor for objects of class Square * * @param s length of sides */ public Square(int s) { super(s,s); } /** * This overrides the method in parent {@link Rectangle} to ensure * that the width and height remain equal. A change to the width * of a Square, changes the height as well. * * @param newWidth the new value */ public void setWidth(int newWidth) { height = width = newWidth; } /** * This overrides the method in parent {@link Rectangle} to ensure * that the width and height remain equal. A change to the height * of a Square, changes the width as well. * * @param newHeight the new value */ public void setHeight(int newHeight) { height = width = newHeight; } } // end of class Square