Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.77 KB | None | 0 0
  1. using System;
  2.  
  3. namespace DrawHeart
  4. {
  5.     class Draw_a_Heart
  6.     {
  7.         static void Main()
  8.         {
  9.             Console.Title = "Draw a Heart";
  10.  
  11.            
  12.             Again:
  13.             try
  14.             {
  15.                 Play:
  16.                 Console.Write("Enter number: ");
  17.                 int n = int.Parse(Console.ReadLine());
  18.                 if(n<=2 || n>35)
  19.                 {
  20.                     Console.WriteLine("Number must be between 3...35");
  21.                     goto Play;
  22.                 }
  23.  
  24.                 int spacesNum = (int)Math.Floor(n / 2.0);
  25.                 int hashesNum = 3;
  26.                 int midSpacesNum = n;
  27.                 char hashes = '#';
  28.                 char spaces = ' ';
  29.                 Console.ForegroundColor = ConsoleColor.Red;
  30.                 Console.WriteLine();
  31.                 Console.WriteLine();
  32.                 for (int i = 0; spacesNum >= 0; i++)
  33.                 {
  34.  
  35.                     Console.WriteLine(new string(spaces, spacesNum) + new string(hashes, hashesNum) + new string(spaces, midSpacesNum) + new string(hashes, hashesNum) + new string(spaces, spacesNum));
  36.                     hashesNum += 2;
  37.                     midSpacesNum -= 2;
  38.                     spacesNum--;
  39.                 }
  40.                 for (int i = 0; i < Math.Floor(n / 2.0); i++)
  41.                 {
  42.                     Console.WriteLine(new string(hashes, 2 * (int)Math.Floor(n / 2.0) + n + 6));
  43.                 }
  44.                 hashesNum = 2 * (int)Math.Floor(n / 2.0) + n + 4;
  45.                 spacesNum = 1;
  46.                 for (int i = 0; i < n + 2; i++)
  47.                 {
  48.                     Console.WriteLine(new string(spaces, spacesNum) + new string(hashes, hashesNum) + new string(spaces, spacesNum));
  49.                     spacesNum++;
  50.                     hashesNum -= 2;
  51.                 }
  52.                 Console.ResetColor();
  53.                 Console.WriteLine();
  54.                 Console.WriteLine();
  55.  
  56.                 Q:
  57.                 Console.Write("Do you want to continue? (Y/N) : ");
  58.  
  59.                 string contin = Console.ReadLine().ToLower();
  60.                 if (contin == "y" || contin == "yes" || contin == "")
  61.                 {
  62.                     Console.Clear();
  63.                     goto Play;
  64.                 }
  65.                 else if (contin == "n" || contin == "no")
  66.                 {
  67.                     Environment.Exit(0);
  68.                 }
  69.                 else
  70.                 {
  71.                     Console.WriteLine("Answer properly");
  72.                     goto Q;
  73.                 }
  74.             }
  75.             catch (Exception)
  76.             {
  77.                 Console.WriteLine("Invalid number !");
  78.                 goto Again;
  79.             }
  80.            
  81.            
  82.         }
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement