/**
 * 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 widthString = "\nShape instance variables: \nThe width is ";
        String all = "";
        all = all.valueOf(width);
        all = widthString.concat(all);
        all = all.concat("\nThe height is ");
        String hs ="";
        hs = hs.valueOf(height);
        all = all.concat(hs);
        all = all.concat("\nThe symbol is ");
        return all = all.concat(symbol + "\n");
    }
     
    /* 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 static void main(String[] args)
     {
       // allocate an object of class Shapes named myshapes

       Shapes shape1 = new Shapes(5, 8, "*");
       Shapes shape2 = new Shapes(6, 4);
       Shapes shape3 = new Shapes();
       
       
       shape3.setWidth(14);
       shape3.setHeight(4);
       System.out.println("The symbol for your shape is " + shape3.getSymbol());
       shape3.setSymbol("<3");
       System.out.println("The symbol for your shape is " + shape3.getSymbol());
       System.out.println(shape3.toString());
       
       shape1.printRectangle();
       shape2.printRectangle();
       shape3.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, "$");


    }
}
