Writing stars with specific shape
<p>i want to write a shape with " * " and " | " the shape is below.
The program must take height and width from user.Width is column number without ' | '.I tried to write but confused.My code sometimes works great and sometimes being stupid.For example when i enter height : 13, width : 4 it writes one more,if witdh is 1 it enters infinite loop.While trying to solve it became too conflicted.Must i fix it or rewrite ? Here is the code : height =10, width = 5</p>

<pre>
|*____|    
|_*___|
|__*__|
|___*_|
|____*|
|___*_|
|__*__|
|_*___|
|*____|
|_*___|
</pre>

<pre><code>      private static void Function()
      {
        int height, width;

        if (width == 2)
            while (height &gt; 0)
            {
                FirstPart(width, height);
                height -= width;
            }
        else
            while (height &gt; 0)
            {
                if (height &gt; 1)
                {
                    FirstPart(width, height);
                    height -= width;
                }
                if (height &gt; 0)
                {
                    SecondPart(width, height);
                    height -= width - 2;
                }
            }
    }


    private static void FirstPart(int width,int height)
    {

        if(height &gt; width)
             for (int i = 0; i &lt; width; i++)
             {
                for (int j = 0; j &lt; width+2; j++)
                {

                    if (j == 0 || j == width + 1)
                        Console.Write("|");
                    else
                         if (i + 1 == j)
                            Console.Write("*");
                         else
                             Console.Write(" ");
                }
             Console.WriteLine();
        }
        else
            for (int i = 0; i &lt; height; i++)
            {
                for (int j = 0; j &lt; width + 2; j++)
                {

                    if (j == 0 || j == width + 1)
                        Console.Write("|");
                    else
                        if (i + 1 == j)
                            Console.Write("*");
                        else
                            Console.Write(" ");
                }
                Console.WriteLine();
            }
    }
    private static void SecondPart(int width,int height)
    {

        if(height &gt; width)

            for (int i = 0; i &lt; width-2; i++)
            {
               for (int j = 0; j &lt; width+2; j++)
               {

                if (j == 0 || j == width + 1)
                    Console.Write("|");
                else
                    if (i + j == width-1)
                        Console.Write("*");
                    else
                        Console.Write(" ");
            }
            Console.WriteLine();
        }
        else
            for (int i = 0; i &lt; height; i++)
            {                                     
                for (int j = 0; j &lt; width + 2; j++)
                {
                    if (j == 0 || j == width + 1)
                        Console.Write("|");
                    else
                        if (i + j == width - 1)
                            Console.Write("*");
                        else
                            Console.Write(" ");
                }
                Console.WriteLine();
            }
    }            
</code></pre>
