Advertisement
Guest User

Untitled

a guest
Jan 26th, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.63 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Eggs
  8. {
  9.     class Eggs
  10.     {
  11.         //egg Top
  12.         public static void eggTop(int eggTopHeight)
  13.         {
  14.             int dotControl = eggTopHeight - 3;
  15.  
  16.             int j = 0;
  17.             StringBuilder line = new StringBuilder("");
  18.  
  19.             for (int i = 0; i < (eggTopHeight / 2) + 1; i++)
  20.             {
  21.                 if (i == eggTopHeight - 1)
  22.                 {
  23.                     break;
  24.                 }
  25.                 line.Append('.', eggTopHeight - j + 1);
  26.  
  27.                 // first line of the top of the egg applied
  28.                 if (j == 0)
  29.                 {
  30.                     line.Append('*', eggTopHeight - 2);
  31.                 }
  32.                 else
  33.                 {
  34.                     line.Append('*');
  35.                 }
  36.                 //dots, which are inner for the egg, growing per 4 on the line starting
  37.                 //from n+1: n = 4; dots at first line = 5, etc.
  38.                 if (j != 0)
  39.                 {
  40.                     dotControl += 4;
  41.                     line.Append('.', dotControl);
  42.                 }
  43.  
  44.                 line.Append('*');
  45.                 line.Append('.', eggTopHeight + 1 - j);
  46.  
  47.                 string resultLine = line.ToString();
  48.                 Console.WriteLine(resultLine);
  49.                 line.Remove(0, resultLine.Length);
  50.                 j += 2;
  51.             }
  52.         }
  53.         public static void eggMiddle(int middleHeight)
  54.         {
  55.             string dot = ".";
  56.             string dIes = "#";
  57.             string middleLine = ".*";
  58.  
  59.             for (int height = 0; height < 2; height++)
  60.             {
  61.                 for (int width = 0; width < 3 * middleHeight - 3; width++)
  62.                 {
  63.                     if (width % 2 == 0)
  64.                     {
  65.                         middleLine += dot;
  66.  
  67.                     }
  68.                     else
  69.                     {
  70.                         middleLine += dIes;
  71.                     }
  72.                 }
  73.                 middleLine += "*.";
  74.                 Console.WriteLine(middleLine);
  75.                 dot = "#";
  76.                 dIes = ".";
  77.                 middleLine = ".*";
  78.             }
  79.         }
  80.         public static void eggBottom(int bottomHeight)
  81.         {
  82.  
  83.         }
  84.         static void Main(string[] args)
  85.         {
  86.             string num = Console.ReadLine();
  87.             int n = Convert.ToInt32(num);
  88.  
  89.  
  90.             //logical parts:
  91.             eggTop(n);
  92.             eggMiddle(n);
  93.             eggBottom(n);
  94.         }
  95.     }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement