/**
 * class Shapes prints out multiple rectangular boxes 
 * 
 * @author Kathryn
 * @version February 2007
 */
import java.util.*;

public class Shapes
{
    // instance variables - encode persistant class state
    
    // The width, height, and symbol for a rectangular box
    // 1. We need to hide these?  What word do we use to hide something?
    private int width = 0;
    private int height = 0;
    private String symbol = "@";
 
    /**
     * 3. Constructor for objects of class Shapes without arguements!
     */

    /**
     * Constructors for objects of class Shapes with arguements
     */
    public Shapes()
    {
    }
    public Shapes(int w, int h)
    {
        // initialize instance variables
        width = w;
        height = h;
    }    
    public Shapes(int w, int h, String s)
    {
        // initialize instance variables
        width = w;
        height = h;
        symbol = s;
    }
    /** 3. Get and Set methods for all class instance variables; we have two
     *     add setSymbol, getSymbol, toString
     */
    public void setWidth(int w) {
        width = w;
    }
    public int getWidth() {
        return width;   
    }
    public void setHeight(int h) {
        height = h;
    }
    public int getHeight() {
        return height;   
    }
    public void setSymbol(String s) {
        symbol = s;
    }
    public String getSymbol() {
        return symbol;
    }
    
    public String toString() {
        String all = "\nShape instance variables: \nThe width is " + width;
        all = all.concat("\nThe height is " + height + "\nThe symbol is " + symbol + "\n");
        return all;

    }
     
    /* printRectangle prints a rectangle with a symbol
     *   @param width
     *   @param height
     *   @param String s
     */
    public void printRectangle() {
        for (int i = 0; i < height; i++){
            for (int j = 0; j < width; j++) {
                System.out.print(symbol);
            }
            System.out.println();
        }
    }
    
    public void printRightTriangle () {
        for (int i = 0; i < width; i++) {
            for (int j = 0; j < i + 1; j++) {
                System.out.print(symbol);
            }
            System.out.println();
        }

    }
    /**
     *  Reads in a postive integer
     * @param systemIn the input console object
     */
    public int getPositiveInt(Scanner systemIn, String sideName){
       int width = 0;
       boolean badWidth = true;

       while (badWidth) {
           // Error checking
           System.out.print("Enter positive integer for " + sideName + ": ");
           if (!systemIn.hasNextInt()) {
               System.out.println("That is not an integer");
               systemIn.next();
           } else {
               width = systemIn.nextInt();
               if (width < 0) {
                    System.out.println("Distances must be positive.");
                }
                else { // width >= 0 and its an integer
                    badWidth = false;
                    // System.out.println("Your box width is: " + width + ".\n"); 

                }
           }
       }
       return width;

    }
    public boolean equals(Shapes other) {
        
        if ((this.width == other.width) && (this.height == other.height ) 
            && (this.symbol.equals(other.symbol))) {
                return true;
        } else {
            return false;
        }
        
    }

    public static void main(String[] args)
     {
       // allocate an object of class Shapes named myshapes
       Shapes[] shapes = new Shapes[3];
       
       shapes[0] = new Shapes(5, 8, "*");
       shapes[1] = shapes[0];
       shapes[2] = new Shapes();
       
       if (shapes[0].equals(shapes[1])) {
           System.out.println("shape1 does equal shape2");
        }
        else {
           System.out.println("shape1 does NOT equal shape2");
        }
       shapes[2].setWidth(14);
       shapes[2].setHeight(4);
       System.out.println("The symbol for your shape is " + shapes[2].getSymbol());
       shapes[2].setSymbol("<3");
       
       System.out.println("The symbol for your shape is " + shapes[2].getSymbol());
       System.out.println(shapes[2].toString());
       
       shapes[0].setWidth(3);
       shapes[0].printRectangle();
       shapes[1].printRectangle();
       shapes[2].printRectangle();
       
       // always allocate a Scanner object for input
//       Scanner stdin = new Scanner(System.in);

//       int width = manyShapes.getPositiveInt(stdin, "width of a rectangle");
//       int height = manyShapes.getPositiveInt(stdin, "height of a rectangle");

 //      manyShapes.printBox(width);
//       System.out.println();

//       int side = manyShapes.getPositiveInt(stdin, "side of a right triangle");
//       manyShapes.printRightTriangle(side, "$");


    }
}
