// Program to do Hourglass case study
public class Hourglass
{
    // constant for size of of hours glass
    public static final int SIZE = 4;
    
    
    // main method draws the hour glass
    public static void main(String[] args)
    {   drawTopBottom();
        drawTopHalfGlass();
        drawBottomHalfGlass();
        drawTopBottom();
    }
    
    // method to draw the top and bottom part of the hour
    // glass. The top and bottom line are the same.
    public static void drawTopBottom()
    {   System.out.print("|");
        int numStars = SIZE * 2 + 1;
        // print out appropriate number of #s
        printString(numStars, "#");
        System.out.println("|");
    }
    
    // Method to draw the top half of the hour glass.
    // number of spaces increases, while *s that
    // represent the glass, decrease
    public static void drawTopHalfGlass()
    {   for(int lineNumber = 1; lineNumber <= SIZE; lineNumber++)
        {   System.out.print("|");
            printString(lineNumber, " ");
            // print out appropriate number of stars
            printString(1 + 2 * (SIZE - lineNumber), "*");
            printString(lineNumber, " ");
            System.out.println("|");
        } // end of lines loop
    }

    // Method to draw the bottom half of the hour glass.
    // number of spaces decreases, while *s that
    // represent the glass, increase.
    public static void drawBottomHalfGlass()
    {   for(int lineNumber = 1; lineNumber <= SIZE; lineNumber++)
        {   System.out.print("|");
            printString(SIZE - lineNumber + 1, " ");
            printString(lineNumber * 2 - 1, "*");
            printString(SIZE - lineNumber + 1, " ");
            System.out.println("|");
        }

    }
    
    // A method to print strings.
    // I expect numTimesToPrint to be >= 0
    // if numTimesToPrint < 0, 0 strings are printed out
    public static void printString(int numTimesToPrint, String st)
    {   for(int i = 1; i <= numTimesToPrint; i++)
        {   System.out.print(st);
        }
    }
      
    
}
